r/PythonLearning

Image 1 — My 1st python project. Suggestion accepted
Image 2 — My 1st python project. Suggestion accepted
Image 3 — My 1st python project. Suggestion accepted
▲ 137 r/PythonLearning+1 crossposts

My 1st python project. Suggestion accepted

This is my 1st python project I did using the knowledge i currently have.

I know that this code is very messy and unreadable(iam a absolute beginner.)

I did use chatgpt to help with choice 2 but I didn't just copy paste the code. I learnt a new function and it's use. - enumerate () function.

Rest all is my idea and my built upon my logic.

- What things could I make it better to make this code readable.

- I don't know about functions and error handling yet.

But when I learn I will implement it in this project.

Your SUGGESTIONS/COMMENTS are highly APPRECIATED :)

u/Muhammed_zeeshan — 8 hours ago

How college students learn Python

I am a college student. I learn knowledge from teachers at school, yet I struggle a lot when writing codes in practice. I have also taken courses on YouTube, but I still find it tough to code on my own. Now I really don’t know how to learn programming well.

reddit.com
u/Straight-Payment-870 — 11 hours ago

If code runs fine, where do bugs come from?

I have been seeing loads of reel on insta this days for coder, where they talk about bugs n fixing bugs, but in real term what is bug, i have been writing codes/script it never failed the pipeline so what actually trigger a bug or they call it fixing bug

reddit.com
u/No-Seaweed-7579 — 15 hours ago

Tried making mandelbrot set in tkinter

`from tkinter import *

gX = 500 gY = 600 COLORS = ["gray99", "gray97", "gray95", "gray93", "gray91", "gray89", "gray87", "gray85", "gray83", "gray81", "gray79", "gray77", "gray75", "gray73", "gray71", "gray69", "gray67", "gray65", "gray63", "gray61", "gray59", "gray57", "gray55", "gray53", "gray51", "gray49", "gray47", "gray45", "gray43", "gray41", "gray39", "gray37", "gray35", "gray33", "gray31", "gray29", "gray27", "gray25", "gray23", "gray21", "gray19", "gray17", "gray15", "gray13", "gray11", "gray9", "gray7", "gray5", "gray3", "gray1"]

set = Tk() set.geometry(f"{gX}x{gY}")

mandelbrotImg = PhotoImage(width=gX, height=gY)

def fractal_build(gX, gY, counterMax, COLORS): f_row=[] for j in range(gX): row0=[] for i in range(gY): cx = -2+(i/gX)(2.5) cy = -1+(j/gY)(2.5) z = complex(0, 0) c = complex(cx, cy) counter = 0 while counter<counterMax: z = z*2+c counter+=1 if abs(z) > 2: break row0.append(COLORS[counter(len(COLORS)-1)//counterMax]) f_row.append(row0) return f_row

mbCanv = Canvas(set, height=gY, width=gX) mbCanv.place(x=0, y=0)

mandelbrot = fractal_build(gX, gY, 100, COLORS)

mandelbrotImg.put(mandelbrot) mbCanv.create_image(0, 0, anchor=NW, image=mandelbrotImg)

set.mainloop()`

u/Homo_Bibite — 16 hours ago

I stopped wasting tine on games and i started learning Python instead🙂

https://preview.redd.it/i01533kchc2h1.png?width=1681&format=png&auto=webp&s=421a45abdd54559c1a14a436082ea3172180f218

A few months ago I used to spend almost my whole day gaming, and honestly I felt like I was wasting a lot of time.

One day I decided to finally change that.

I uninstalled my custom Minecraft client — something I had spent a huge amount of time on 😭

At first it felt terrible because I thought I wasted so much effort and time.

Then I started watching random programming videos without really knowing what I was doing.

Eventually I found a roadmap video, searched for a Python course, and started learning with Bro Code’s Python course.

Since then I’ve been trying to learn consistently and build projects instead of only watching tutorials.

At the same time, I started building my first Python project 👇

https://github.com/mohamed-hisham-swidan/game-project/blob/main/README.md

While building it I learned:

  • basic OOP
  • JSON save systems
  • Git/GitHub
  • debugging
  • project structure

I still have a lot to learn, but I’m happy that I finally started building real things instead of just consuming content all day 😅

reddit.com
u/Warm-Inside-4108 — 1 day ago

Coding with mosh's program error problem

Guys please someone help I m a perfect newbie trying to learn python basics in aiml from the yt channel coding with mosh's 6 ur lecture but this particular program I have written exactly as he has done it, but it still shows error, please help some one

u/Frequent_Leg9210 — 1 day ago

Learning python to get scholarship...

I am 15M, I make a few hundred dollars currently off minecraft but I don't see that as a viable source of income in the future. I want to get started on programming to get a head start. I am doing olevel and will be doing alevel soon. I hope to score scholarship for alevel based on my grades but I know scholarships for universities are harder to get in my country so I thought of learning a coding language to make myself a portfolio.

I have being into skriptlang and learnt python 2 years ago. My foundation are shaky and I have forgotten most of it. Can someone recommend some youtube playlist which can help me learn basic python. I know just watching will be no good and I will need to practice but I need to build up my basics first.

Edit: I am doing bro code python course and then going to make some basic python projects. Numpy and madlib (i didn't get the name right) are the frameworks, imma learn. My goal is to make some physics simulation programs as they seem fun..

reddit.com
u/Sea-Car-3811 — 1 day ago

my first mini game!

any advice or input of any kind is much appreciated. i had a line to prevent it from breaking if a player tried to input something not on the list, like "banana" or something, and it was work perfectly, but when i went to test it this morning before posting the line was broken and i don't understand why. so i had to remove it. so as long as you don't try to confuse it or misspell anything (my biggest sin) it should run fine. I've only been coding for about a month so I'm pretty proud that this thing works at all.

edit: i guess i'm stupid for thinking that adding the link would make it available to anyone who wanted it .

[link to .py](https://drive.google.com/file/d/1lo2mEN0IGGN7BUXF50sQdgGXh\_ZOylPY/view?usp=sharing)

u/Mean-Career-6509 — 1 day ago

Im new

I just started with python today and made this project just because I needed something to make to see if I was good enough using my skills I learned. Does anyone have any tips to refine this? Or how I could add it to a website to give it a proper UI?

u/Dismal_Future_54 — 2 days ago

AI/ML

Idk how it sounds but I’m planning to start Python completely from scratch and eventually move into AI/ML, GenAI, Data Engineering, and scalable systems with tools like PySpark, Docker, Kubernetes, FastAPI, cloud, etc.

Can someone suggest a proper roadmap for this journey? Also looking for the BEST YouTube tutorials, playlists, Udemy courses Idc even it’s time consuming. Pretty please !!

reddit.com

y'all git is my new learning superpower

i've been writing code or playing with it for decades. Never bothered to use git except to get projects to install and run for ages. I never coded with anyone else, juset me, myself, and I so it didn't seem too important. The last year or two i started using it. I just now, since i have to learn it because i started a job as an intern. Instantly I knew how important it was. Now after learning an hour in....holy crap. I can see every commit, for every version or branch and why for an entire mature codebase. That's the best teaching tool ever. I can legit step through the entire pypi library. Nothing cooler that I've learned to date.

reddit.com
u/tech53 — 2 days ago

I'm new to coding, and this is the first useful code ive made for myself

hi, ive recently started to learn Python as my first coding language. And to be honest, i wasn't really serious about it. Because i used to do simple stuff that i enjoyed such as a Cubic Equation Solver. It may not be as efficient (not including imports which directly solve it), but it was fun.

but finally, i tried to do something which is useful for me. That is, a calorie counting program.

i believe i spent like 5 hours continuosly, really invested, and learning new terms.

I still plan on adding more features such as:

Including Fats
Increase food dictionary
allow plural forms of food.
Adding more words for "yes"
Make sub-dictionaries for different types of foods, with sub-dictionaries within it for servings (might get too complicated)

Feel free to test it out!

def float_checker(val):
    while True:
        try:
          return  float(input(val))
        except:
            print("Please enter a number!")

maintenance_cal = round(float_checker("Enter your Daily Maintenance Calories: "))
deficit_cal = round(float_checker("What is your Daily Target Deficit? "))
body_weight = float_checker("Enter you Body Weight (Kg): ")
target_calories = maintenance_cal - deficit_cal
req_pro = round(2 * body_weight)
fat_loss_calc_weekly = round(deficit_cal / 1.1)

deficit_percent = round((100 * deficit_cal / maintenance_cal))
repeat_text = f'Your Deficit Percentage: {deficit_percent}% is '
if deficit_percent &lt; 0:
    print(f"{repeat_text}in the negatives! You are GAINING calories.")
elif 0 &lt;= deficit_percent &lt;10:
    print(f"{repeat_text}Mild for fat loss.")
elif 10 &lt;= deficit_percent &lt; 20:
    print(f"{repeat_text}Optimal for fat loss.")
elif 20 &lt;= deficit_percent &lt; 30:
    print(f"{repeat_text}Aggressive for short-term fat loss.")
elif 30 &lt;= deficit_percent:
    print(f"{repeat_text}DANGEROUS! Please increase your intake!")

print(f"Approximate Weekly Fat Loss = {fat_loss_calc_weekly}g")


foods = {
    #SERVING SIZE: 1 UNIT
     "egg": {"calories": 80, "protein": 6}, "chicken breast": {"calories": 145, "protein": 36},
    #SERVING SIZE: 1 SCOOP : 35g
         "whey": {"calories": 125, "protein": 25},
    #SERVING SIZE: 1mL/1g
    "curds": {"calories": 0.65, "protein": 0.04}, "milk": {"calories": 0.5, "protein": 0.04},
    #SERVING SIZE: 1 Heap tbsp
    "peanut butter": {"calories": 165, "protein": 7}, "hummus": {"calories": 35, "protein": 1.5},
         }


print("NEW DAY: ")
print(f"TODAY PROTEIN REQUIREMENT: {req_pro}g")
print(f"TODAY CALORIE REQUIREMENT: {target_calories}kcal")

sum_cal = 0
sum_pro = 0

yes_response = ["yes", "yep", "y" , "ok" , "okay", "ye"]

confirmation = input("Have you had anything? ").lower()

while confirmation in yes_response:

    food = input("What have you had? ").lower()

    if food not in foods:
        print("Enter a valid food!")
        continue

    else:
        servings = float_checker("How many servings? [1 UNIT / 1 SCOOP / 1 mL / 1 HEAPED TBSP] ")

        f_cal = foods[food]["calories"]
        f_pro = foods[food]["protein"]

        sum_cal = round(f_cal * servings + sum_cal)
        sum_pro = round(f_pro * servings + sum_pro)

        print(f"{sum_cal} kcal consumed today")
        if sum_cal &gt;= target_calories:
            print(f"You've exceeded your caloric intake by {sum_cal - target_calories} kcal!")
        else:
            print(f"{target_calories - sum_cal} kcal remaining today")

        print(f"{sum_pro} g Protein consumed today")
        if sum_pro &gt;= req_pro:
            print(f"You've crossed your Protein Requirement by {sum_pro - req_pro}g!")
        else:
            print(f"{req_pro - sum_pro} g Protein remaining")

    confirmation = input("Have you had anything else? ").lower()

    if confirmation not in yes_response:
        print("Good Luck!")
reddit.com
u/LeatherSet9012 — 1 day ago

how do i learn python

i dont know anything about coding with pyton but i want to learn how to do it. when i check tutorials their pythons looks diffirent then mine. mine is j ust like aa p lain text file but heirs has fetaures they have commandss they can use shown or something like that idk. i dont know where to start

reddit.com
u/Key-Relative-4380 — 2 days ago

Stoned coding, yea or nea?

I say it's the only way to code. Especially with ML, data science, or AI. Others may have different views.

reddit.com
u/tech53 — 2 days ago

Making a motivational quote generator, what am I doing wrong?

I'm relatively new to Python (3 weeks?)

Still trying to get a grasp on everyhting and working on a project to get better. When it comes time to enter a number from 1-10 it just repeats the number back to me.

I feel like dumb for asking, but that's the only way to learn! Could you guys help me and shine some light on the issue.

u/Few_Doctor5328 — 3 days ago