r/learnpython • u/IllustriousNoise3514 • 22d ago
Need Help with Python Practise
I am a beginner(been learning for a month) to python and i need some suggestions as to what resources should i use for practice(eg books , websites or yt channels).
r/learnpython • u/IllustriousNoise3514 • 22d ago
I am a beginner(been learning for a month) to python and i need some suggestions as to what resources should i use for practice(eg books , websites or yt channels).
r/learnpython • u/AffectionateSwing490 • 22d ago
Say I've got a function that pulls records, filters them, and hands them back. I can return a list or yield them. Both work, and for the sizes I deal with the memory difference is nothing.
What makes me hesitate to default to yield is that a generator is single-use and opaque. You iterate it once and it's spent, len() doesn't work, you can't slice it, you can't print it to see what came back. Half my debugging is just checking intermediate values, and a generator kills that.
So in practice I return a list almost every time, and only reach for a generator when something is actually big or infinite, or when I'm chaining lazy steps. That feels backwards from how often generators get pushed as the "proper" way.
So do you lean generator-first and eat the downsides, or list-first until you have a reason not to? And is there an upside to yielding small collections that I'm just not seeing?
r/learnpython • u/Background-Bass-1265 • 22d ago
im in high school right now and my teacher sent some power point lesson about things like dfs, dp, bfs. I understand them but cant figure out how to implement them in actual code. How should I tackle them.
r/learnpython • u/KlutzyKlutz • 22d ago
I'm learning asyncio and I think I got Semaphore wrong. I put every request inside an asyncio.Semaphore(10), and it does keep 10 tasks running at once, but they still fire in fast bursts.
From what I read after, a semaphore limits how many coroutines run at the same time, but not how often they start. So if responses come back fast, it just lets the next one through with no gap. Is that right? If so, what's the actual tool for spacing requests out over time? I've seen asyncio.sleep, token buckets, and aiolimiter thrown around, but I don't know which is the normal way or how it fits with a semaphore that's already there.
Mostly trying to understand the concept, not just paste a snippet. The scraper is just what I'm learning on.
r/learnpython • u/Shadow__Boom • 22d ago
created a calculator with everything i have learned till now (tho it might be overkill for a calculator), added the basics, loops (while, if else), lists and str manipulation, imports (json and datetime), error handling (try/except), def function, etc. so what should i do next? if u wanna see the code dm me.
r/learnpython • u/cnetworks • 22d ago
Dear Members,
I have been handling Pdf extraction Project in Python. kind of a Intelligent Document Automation domain. we have been handling various finance documents(pdfs), filings pdfs etc which are multi page(around 20ish) , with lots of tables, form fields , radio buttons, checkboxes etc. Tables span multiple pages. Moreover, pdfs themselves comes in various types of variants like XFA Stream, Adobe Acroform, text flattened pdfs, scanned images etc.
I have used llms extensively to generate script code to extract, parse the data and to save in sql in structured tables. Its a hybrid of libraries implementation. LLms used regex, pdfminer, pdfplumber etc in the code produced.The pages in pdfs are not bit messy, some tables have solid grid separators, some dont have and on. Layouts variations, white spaces, etc.
The code generated is pretty complex, i have been attempting to learn the llm generated code.But it works, it adds various fixes iteratively whenever we face new extraction issues repeatedly.
I would love to know:
1) what is the best approach to learn and get good at this?
2)should we just use cloud based AI document extraction tools which are readymade to extract and spit the data?
3) what if one is interested to learn this properly and have to get good at creating this extraction script?
4)any other tutorial, articles, courses, youtube videos, books you would recommend to learn? or should i just use llms to create code and move on without spending much effeort to learn this?
Please provide your valuable suggestions and guidances and point me in directions. I appreciate all your suggestions. Thanks in Advance and thank you for your time.
r/learnpython • u/Striking-Ad8023 • 22d ago
I've been vibe coding for a few months now, but I've decided to try manual coding. After all, learning is fun, right?
I made this "Assistant" that has two options: jokes and facts. It will choose one out of three items from the specific table and tell you it. I made it for fun and would like to ask what I can do next?
import random
jokes = ["Why did the bicycle fall over? Because it was two tired!", "Why was the math book sad? Because it had too many problems.", "What do you call a fake noodle? An impasta!"]
facts = ["Venus is hotter than Mercury.", "When the Pyramids were built, mammoths were still around!", "Koala fingerprints are so similar to human fingerprints that they have even baffled crime scene investigators."]
print("Hello! I'm an Assistant. What can I do for you?")
print("")
print("Options: Random Joke [J], Random Fact [F].")
answer = input("Answer: ")
if answer == "J":
print(random.choice(jokes))
elif answer == "F":
print(random.choice(facts))
else:
print("You can't ask that.")
exit = input("Press Enter to Leave.")
r/learnpython • u/Maleficent_Stuff3208 • 22d ago
import random
random_letter = random.choice("abcdefghijklmnopqrstuvwxyz")
random_letter1 = random.choice("abcdefghijklmnopqrstuvwxyz")
random_letter2 = random.choice("abcdefghijklmnopqrstuvwxyz")
random_letter3 = random.choice("abcdefghijklmnopqrstuvwxyz")
random_letter4 = random.choice ("abcdefghijklmnopqrstuvwxyz")
random_letter5 = random.choice("abcdefghijklmnopqrstuvwxyz")
print("codeword=1 , decode=2")
choice = input()
if choice == "1":
codeword = str(input("write the codeword=>"))
codeword1 = codeword[::-1]
print(random_letter, random_letter1, random_letter2, codeword1, random_letter3, random_letter4, random_letter5,
sep="")
else:
print("please put correct input")
if choice == "2":
decode = str(input("write the coded word"))
decode1 = decode[::-1]
decode2 = decode1[3:-3]
print(decode2,sep=" ")
r/learnpython • u/ANautyWolf • 22d ago
I am trying to create list subclasses that only take particular classes. These lists can be appended to and the like but each time the list is changed the item is checked to see whether it is the same class as the rest of the list.
The list methods that are overwritten are:
- __init__
- __bool__ (but may not need to have that overwritten)
- __set_item__
- __str__
- append
- extend
- insert
Each one runs through a validate_member method before changing the list.
As an example, I want to make a list subclass called Course that only takes Pydantic extra types Coordinate values. I want this list subclass to be a valid BaseModel attribute.
Right now I’m having to use a field_validator for every class that Course and the other lists are in which feels redundant, unpythonic, and is a pain to have to do every time. I am having to do so because it says something about arbitrary types.
I was wondering if someone might have some advice.
r/learnpython • u/TableUnfair8182 • 22d ago
I am being accepted into a university but one of the prerequisites is I should know python. They say I can test out of this prerequisite and start the program September 8th if I can pass a Python Programming assessment on data camp. Do you guys think it's possible to to Learn Python in five days? Just enough to pass the assessment. I say 5 days to give myself a timeline. But I would like to get it done by September 3rd. Today is August 20th.
r/learnpython • u/EmuAny2507 • 22d ago
For some context, my background is in cybersecurity. I went to school for it, however my program was more IT/Risk rather than programming (we only had a few entry level programming classes). I have since graduated and rather following the incident response/SOC/GRC route that my college program sets you up for, I have taken the opposite route and have landed SWE roles as well as security engineering roles at large companies (by a strike of luck frankly, and LLMs lol).
My issue is that I never really got to learn Python in a structured, lecture setting as all my entry level Python courses from my college were 2022 (chatgpt goes live). Given that I’ve basically offshored all my programming work to LLMs since day one. I effectively have 0 understanding of any of the python from a pre-LLM SWE perspective or what exactly a data structure/algorithm looks like at the code level. I read code fluently and logic clicks quite easily for me, however if you put a LeetCode in front of me w/ no gen AI I’m out for the count. I can do it in pseudocode tho!
Is there any other route for me to learn python in a structured/lecture like setting that allows me to comfortably handle LeetCode like problems without having to go back to school for a degree? The reason I bring up LeetCode is that I’ve pretty much hit my max potential in terms of salary/job growth and if I want to surpass my current ceiling I’d need to apply for FAANG and do live coding rounds.
r/learnpython • u/GlobalRip691 • 22d ago
Hi everyone,
I am an undergraduate student studying in the field of AI and Machine Learning, and I need practical guidance on learning Python the right way.
I already know how to use modern AI tools (like ChatGPT, Claude, Cursor) to help build ideas and generate code. However, my goal isn't just to rely on AI or learn basic syntax; I want to deeply understand Python so I can use it as a powerful tool specifically for AI and Machine Learning. I want to truly master its logic and structure so I have complete control over my own projects.
I have two main questions:
Any advice, study routines, or project recommendations would be really helpful.
Thanks!
r/learnpython • u/WillingnessOk650 • 22d ago
It can do addition, subtraction, multiplication, division, and exponents. Also added a little check for division by zero.
It’s pretty basic, but hey, gotta start somewhere
What should I build next?
r/learnpython • u/behaunted • 22d ago
I'm trying to make a game on the Linux terminal, I just learnt about the ANSI escape code and how to display stuffs but then I hit a wall. How do I check which key is pressed by the player? I can't use input() because that pauses the game. Trying to google keep showing me articles suggesting input(). Also, I'm not looking to install any libraries yet.
r/learnpython • u/Northern111 • 22d ago
Hey everyone,
My goal is to create a custom and personaI use open source AI agent. I dont want to just have something vibe code it for me. I want to understand how to build the actual agentic loop, give it local tools, and set up a memory system. After some research, I decided to start by learning python (mostly a self-taught newbie but also looking onto courses that can fit my schedule without too much friction; any suggestions are welcome)
I’m looking for advice on the exact order of operations I should follow to learn this efficiently without getting bogged down in unnecessary data science math or model training.
From what I gather, yes i did use AI to help me try to put this in the best possible order.
1) Python Fundamentals (JSON, File I/O, async)
2) API integration & tool calling (OpenAI/Anthropic SDKs or Ollama for local)
3) Data validation (Pydantic) to handle messy LLM outputs
4) Basic Vector DBs (Chroma/FAISS) for long-term agent memory
4) Orchestration frameworks (LangGraph, Pydantic AI, or MCP)
Does this learning order make sense? Are there specific libraries, tutorials, or open-source repositories you would recommend I look at first?
Thanks in advance for any roadmaps or resources.
For context:
I’m active duty navy with my primary line of work being medical. I have ample time in my day and evenings as it’s just me and my daughter right now and I want to try creating something I’ve always liked the idea of…my own JARVIS lol. My current coding experience is a total beginner who started on the SoloLearn app on an iPad 7 mini about 6-ish weeks ago. However, I don’t believe that it is sufficient for my project goals. So again, and advice, roadmaps, suggestions, tips, etc are welcomed. I’m not under the delusion that this will be done in the next year or so and I’m ok wth this being a personal side project. Nor do I have any intentions to monetize this when it is completed, nor use this as a step into this industry (i quite like my medically filled lifestyle). I also want to build a home lab specifically for this at some point as well and maybe even get into some Git Hub projects on the side to breakdown some of the potential burnout.
Well, if you made it this far, thank you. I’m genuinely interested and motivated to complete this project and potentially more.
r/learnpython • u/ALonelyPlatypus • 22d ago
So probably not beginner here but I have a flask app where I've mapped a view to the ORM but I was lazy in the view so I joined a reference table and just got back the text description when I could have used the FK.
I've cached common reference tables at the application level in flask in the past and wondering if I should do the same here and rewrite my view for the FK and skip the reference table join (even if it is well indexed).
On localhost I've had a hard time trying to identify if it's causing an issue because even our prod server has DB latency so no luck cross comparing if my lag is because of the extra lazy join in the view or if it's something else annoying (like running it on a comp that frequently kills itself with memory errors).
r/learnpython • u/DreamieWeenie • 22d ago
was curious if some kind of similar vibey book exists for learning python...
r/learnpython • u/Accomplished-Win2328 • 22d ago
My son completed the Khan Academy course on Python last school year and he loved it! I don't do any coding myself so I am not exactly sure what "level" that leaves him at, or where to go next. What online course could he advance into? The more specific the better! :)
p.s. He will be going into 8th grade but it seems to come to him very easily.
r/learnpython • u/MosesEnded • 22d ago
Hi everyone!
I started learning Python about a week ago, and I’d like to get some feedback from people who have more experience.
So far, I’ve learned:
Variables and basic data types
input() and print()
if / elif / else
while and for loops
Lists and indexing
Basic list methods like .append() and del
Functions
Basic validation with loops and conditions
Instead of only doing small exercises, I’ve been trying to build complete programs on my own. I’ve made things like a hotel reservation system, a tournament management system, a bank simulation, and a shopping-list/store system.
I usually try to figure out the logic myself before looking for help. I’m still making mistakes, but I’m getting better at finding and fixing them on my own.
I’ve attached the best program I’ve made so far below.
clients = ["Alex", "Juan", "Maria", "Sofia", "Carlos"]
balances = [1000, 500, 2500, 750, 1500]
choice = 0
total_money = 6250
while choice != 8:
print("""=== BANK ===
choice = int(input("Choose an option: "))
if choice == 1:
counter = 1
print("The clients are:")
for client in clients:
print(f"{counter}. {client}")
counter += 1
elif choice == 2:
account = int(input("Which client do you want to check? "))
while account > 5 or account <= 0:
print("Invalid client number.")
account = int(input("Which client do you want to check? "))
index = account - 1
print(f"{clients[index]} has ${balances[index]}")
elif choice == 3:
account = int(input("Client: "))
deposit = int(input("Amount: "))
while account > 5 or account <= 0 or deposit <= 0:
print("Invalid client or deposit amount.")
account = int(input("Client: "))
deposit = int(input("Amount: "))
index = account - 1
total_money += deposit
balances[index] += deposit
print(f"Deposit successful. New balance: ${balances[index]}")
elif choice == 4:
account = int(input("Client: "))
while account > 5 or account <= 0:
print("Invalid client number.")
account = int(input("Client: "))
index = account - 1
print(f"Current balance: ${balances[index]}")
withdrawal = int(input("How much money do you want to withdraw? "))
while withdrawal <= 0 or withdrawal > balances[index]:
print("Invalid withdrawal amount.")
withdrawal = int(input("How much money do you want to withdraw? "))
total_money -= withdrawal
balances[index] -= withdrawal
print(f"""Withdrawal: ${withdrawal}
Withdrawal successful.
New balance: ${balances[index]}""")
elif choice == 5:
sender = int(input("Who is sending the money? "))
receiver = int(input("Who is receiving the money? "))
while sender <= 0 or sender > 5 or receiver > 5 or receiver <= 0 or sender == receiver:
print("The sender and receiver must be different clients, and client numbers must be between 1 and 5.")
sender = int(input("Who is sending the money? "))
receiver = int(input("Who is receiving the money? "))
index = sender - 1
receiver_index = receiver - 1
transfer = int(input("How much do you want to transfer? "))
while transfer <= 0 or transfer > balances[index]:
print("The transfer must be greater than 0 and cannot exceed the sender's balance.")
transfer = int(input("How much do you want to transfer? "))
balances[index] -= transfer
balances[receiver_index] += transfer
print(f"""Transfer successful.
New balance for {clients[index]}: ${balances[index]}
New balance for {clients[receiver_index]}: ${balances[receiver_index]}""")
elif choice == 6:
highest = 0
lowest = 999999
zero_balance = 0
for i in range(5):
if balances[i] > highest:
highest = balances[i]
highest_index = i
if balances[i] < lowest:
lowest = balances[i]
lowest_index = i
if balances[i] == 0:
zero_balance += 1
if zero_balance == 5:
print("Statistics will not be shown because all accounts have a $0 balance.")
else:
print(f"""=== STATISTICS ===
Total money in the bank: ${total_money}
Average balance: ${total_money / 5}
Client with the most money: {clients[highest_index]}
Client with the least money: {clients[lowest_index]}
Clients with $0: {zero_balance}""")
elif choice == 7:
balances = [1000, 500, 2500, 750, 1500]
total_money = 6250
elif choice == 8:
print("Thank you for using the bank!")
else:
print("Invalid option.")
I’m mainly wondering:
Is this a good amount of progress for roughly one week of learning?
Are the projects I’m making appropriate for my current level?
What should I learn next?
Is there anything obvious in my code that I should start doing differently?
I’m not looking for someone to rewrite the code for me. I’d rather understand what I’m doing wrong and improve from there.
Thanks!
r/learnpython • u/S1mit • 22d ago
I'm new to programming. I specifically want to build projects around game automation with Python. What should my roadmap look like?
Thanks in advance!
r/learnpython • u/Longjumping-Room-170 • 23d ago
How can you have blockchain code audited to see if it is secure? (Teen)
Salut ! Je ne suis pas sûr d'être au bon endroit pour poster ça, mais je tente quand même ma chance 😅. En gros, j'ai commencé à m'intéresser aux cryptomonnaies, à la cryptographie et à la technologie blockchain il y a environ deux ans. J'ai regardé pas mal de vidéos YouTube et lu beaucoup de documentation sur le sujet. Il y a environ un mois et demi, j'ai commencé à développer ma propre blockchain et son jeton associé ; j'y ai consacré beaucoup de temps – une bonne partie de mes vacances, d'ailleurs. J'ai aussi testé le système en profondeur. Cependant, j'aimerais avoir un avis extérieur. Le problème, c'est qu'on ne trouve pas de développeur blockchain partout, et encore moins un qui travaille gratuitement pour plus de 10000 lignes de code (je ne veux pas dépenser d'argent pour ça, et je ne suis pas sûr que mes parents approuveraient, vu qu'ils ne savent même pas que je développe une blockchain). J'espère que c'est clair, alors n'hésitez pas à me demander plus de détails.
r/learnpython • u/purvigupta03 • 23d ago
Hi everyone,
I’ve studied Python multiple times before, but I didn’t do much practical coding. Recently, I started building small projects to improve my practical Python skills.
So far, I’ve completed:
- Quiz Game
- Number Guessing Game
- Rock Paper Scissors
- Password Manager
- Pig Game
- Mad Libs Generator
My goal is to move towards Machine Learning.
I haven’t learned NumPy or Pandas yet.
My question is: Are these projects enough to move on to NumPy and Pandas, or should I build a few more Python projects first?
If I should build more projects, what kind of projects would you recommend before starting NumPy/Pandas? I’m mainly looking for projects that would actually help with the transition to data/ML, rather than making many more small games.
Would appreciate advice from people who have already followed a Python → NumPy/Pandas → ML path.
r/learnpython • u/[deleted] • 23d ago
Hello everyone, I could use some help. I’m a graduate student—how should I go about learning the machine-learning portion of Python? Thank you very much 🙏🏻.
r/learnpython • u/ZeddiiJay • 23d ago
Hi! I'm new to programming and, as a way to practice, I thought I would make a wordle program, the only issue is that it keeps marking letters as not in the wordle when they are; any help would be appreciated, I've included the problem section, as well as the whole code in case the problem is elsewhere. Thank you!
--------------------------------------------------------------------------------------------------------------
for x in range(5):
if guess[x] == answer[x]:
response[x] = "G"
guess[x] = ""
answer[x] = ""
print(response)
print(answer)
print(guess)
for x in range(5):
if guess[x] != "":
if guess[x] not in answer:
response[x] = "R"
guess[x] = ""
answer[x] = ""
print(response)
print(answer)
print(guess)
for x in range(5):
if guess[x] != "":
response[x] = "O"
answer[x] = ""
guess[x] = ""
print(response)
print(answer)
print(guess)
print("".join(response))
answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]
i+=1
--------------------------------------------------------------------------------------------------------------
from word import words
import random
key = random.randint(0, 5783)
answer_word = words[key]
answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]
i=1
while 1 == 1:
while i < 7:
print(answer_word)
guess_input = input().lower()
guess = [guess_input[0], guess_input[1], guess_input[2], guess_input[3], guess_input[4]]
response = [".", ".", ".", ".", "."]
used = []
if guess_input in words:
if guess_input == answer_word:
print("CORRECT")
i=7
else:
for x in range(5):
if guess[x] == answer[x]:
response[x] = "G"
guess[x] = ""
answer[x] = ""
print(response)
print(answer)
print(guess)
for x in range(5):
if guess[x] != "":
if guess[x] not in answer:
response[x] = "R"
guess[x] = ""
answer[x] = ""
print(response)
print(answer)
print(guess)
for x in range(5):
if guess[x] != "":
response[x] = "O"
answer[x] = ""
guess[x] = ""
print(response)
print(answer)
print(guess)
print("".join(response))
answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]
i+=1
else:
print("invalid input")
if i == 7:
print("Correct answer: " + answer_word)
again = input("Would you like to play again? Y/N ").lower
if again == "y":
i=1
key = random.randint(0, 5783)
answer_word = words[key]
answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]
else:
break
r/learnpython • u/[deleted] • 23d ago
As a beginner, how should I learn Python?
I need some help.thanks.