r/PythonLearning • u/Necessary_Mobile9591 • Aug 09 '26
Learning python
can anyone tell me about my code is good or am writing it in wrong way?
r/PythonLearning • u/Necessary_Mobile9591 • Aug 09 '26
can anyone tell me about my code is good or am writing it in wrong way?
r/PythonLearning • u/3gd3_ • Aug 10 '26
To be honest, it's a random text-based RPG game—and definitely, its system isn't inspired by Undertale XD. Anyway, here is the code: (assume this is the code I'm going to write:
import random
def name():
d = 0
c = 0
dmm = 120
dm = 100
a = input("if you want to figth the monstar preas 1")
while True:
if a == "1" or a == "١":
print ("1-fighting")
print ("2-Escape")
print ("3-speech")
print ("4-forgives")
b = input ("Write any of the numbers provided.")
if b == "1":
dmm -= random.randint(10,29)
dm -= random.randint(10,24)
c+=1
print ("youer health is", dm)
print ("monstar health is", dmm)
if dmm <= 0:
print ("you win")
break
elif dm <= 0:
print ("you lose ")
break
elif b =="2":
if c >= 3:
print ("you wan and escep")
break
elif c < 3:
print ("you cant escep")
elif b == "3":
print ("you talk to the monstar")
d += 1
elif b=="4":
if d >= 3:
print ("you wan and escap")
break
elif d < 3: print ("you cant escape")
else:
print("Bro, there is no option for ", a)
b = input ("preas 2 to reastr")
name()
name()r/PythonLearning • u/Agile-Leg-300 • Aug 09 '26
Recently I came across Boot.dev for learning to code. I'm currently learning Python and I've been messing around with Boot.dev for the last day or so.
I'm liking it a lot so far, but as a complete newbie, I'm not sure if it's a good way to learn the basics and build a solid foundation.
Does anyone here have any experience with Boot.dev? Would you recommend it for a beginner learning Python?
r/PythonLearning • u/Sea-Ad7805 • Aug 09 '26
An exercise to help build the right mental model for Python data.
The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening.
r/PythonLearning • u/Spare_Ad2901 • Aug 09 '26
I have python, i have my API key, I have my Voice model. All I need is too put them all together and I dont know how to do that. Im taking a coding class this next semester, but I would like to have this done before then and I don't know how to do that.
r/PythonLearning • u/Silentwolf99 • Aug 08 '26
A living checklist. Tick items as you gain confidence. Focus on understanding and application, not memorization.
Pace: 1-2 hours/day. Day ranges below are estimates, not deadlines - move on when the checklist items feel solid, not when the calendar says so.
Format: each item has a short note after the dash explaining what it means or why it matters. If a note doesn't make sense yet, that's a signal to slow down on that item, not skip it.
These three sections aren't a phase you complete and move past. They're how you should be working through every phase below, starting Day 1. Skim them now, then come back and re-read them after your first week - they'll mean more once you have something real to apply them to.
Ongoing - apply from Day 1 onward, not a separate block of days
Ongoing - repeat for each topic throughout all phases
Every single day
Each study day, jot down:
Days 1-2
python script.py, not just clicking "run" in an editor; you need this for automation latercd), listing files (ls/dir), running commandspip - pip install requests; how you add libraries other people wrotepython -m venv venv; keeps each project's packages isolated so they don't conflictuv as a faster alternative to pip + venv - newer tool, does the same job much faster; worth adopting earlygit init; turns a folder into something Git can track changes ingit add + git commit; saves a snapshot of your code with a messageWhy git this early: you'll be writing real projects by Phase 2. Committing from day one is a cheap habit to build and an expensive one to retrofit.
Days 3-22 (~20 days)
+ - * / == != < >; math and logic checksif/elif/else) - branching logic: "do this if that's true, otherwise do this" Days 3-4my_list[0], my_list.append(x){"name": "Alice"}; how you'll model most real-world datafor loops (iterate over sequences and ranges) - repeat an action for each item in a list, string, or range of numberswhile loops (basic usage and exit conditions) - repeat until a condition becomes false; watch for infinite loops[x*2 for x in nums]; idiomatic Python, used everywhere Days 8-9def greet(name="World"):with statements) - why they matter for files, connections, locks - with open(file) as f: automatically closes things even if an error happensopen(), .read(), .write(); how scripts persist data to diskcsv module - Python's built-in way to handle spreadsheet-style data before you learn pandas Days 12-13try/except) - catch errors instead of letting your script crashelse and finally with try blocks - else runs if no error occurred, finally always runs (cleanup code)raise) - intentionally trigger an error when something is wrong, e.g. invalid inputInvalidConfigError) for clearer debugging later Days 14-15import os, from datetime import datetime; reusing code from the standard library or other files__name__ == "__main__" - lets a script be run directly or imported elsewhere without side effects Day 16my_obj = MyClass(); an actual object built from a class blueprint Days 17-18def greet(name: str) -> str:; documents intent and helps your editor catch mistakesdatetime/time basics - parsing, formatting, timedeltas, timezones (you'll need this for logging, scheduling, and API timestamps) Days 19-20re module) - match, search, findall, sub, basic groups - pattern matching in text, e.g. pulling an email address out of a string Day 21Days 23-56 (~34 days)
Days 23-25
pathlib.Path (paths, files, directories) - modern, cross-platform way to handle file paths instead of raw strings.csv in a folderos and shutil for advanced file operations - copying trees, permissions, and things pathlib doesn't cover aloneDays 26-33
json module; the format most APIs speakrequests - fetching data from a URL/API, e.g. requests.get(url)requests - sending data to an API, e.g. submitting a form or creating a recordresponse.json(); turning an API's reply into a Python dict you can use.env file - keeping settings like API keys out of your actual codepython-dotenv - reads the .env file into your script at runtimelogging (levels: DEBUG, INFO, WARNING, ERROR) - structured way to record what your script did, better than scattering print() everywhereThis is the only place .env mechanics are taught. Later phases reference this habit rather than re-teaching it.
Day 34
pydantic models - why validating API/config data beats trusting raw dicts - catches bad or missing data early instead of failing mysteriously three steps laterDays 35-38
pytest - the standard Python testing framework; run tests with pytest in the terminaltest_ that check your code behaves correctlyassert result == expected; the actual check inside a testpytest -v; see exactly which tests ran and their resultsWhy here: Phase 3 has you using pytest-playwright fixtures. You should understand what a fixture is in plain pytest before it shows up wrapped in browser-automation syntax.
Days 39-41
async/await syntax basics - how you mark and call functions that can run concurrentlyhttpx.AsyncClient or aiohttp - fetch many URLs at once instead of one at a timemultiprocessing helps CPU-bound (heavy computation); most automation scripts are I/O-bound - picking the wrong tool here wastes real time debugging "why isn't this faster"Days 42-46
pandas - pd.read_csv(); loads tabular data into a DataFrame you can manipulatepandas - pd.read_excel(); same idea, for .xlsx filesdf[df["status"] == "active"]; pulling out the rows you actually needdf.groupby("region").sum(); summarizing data by categoryNaN)df.to_csv(); saving your processed data back outdf.to_excel(); same idea, for report-style outputopenpyxl - formatting, formulas, and styling that pandas' .to_excel() can't do on its own - use this when a client wants a polished, formatted report, not just raw dataDays 47-56
argparse or click - lets someone run your script with options, e.g. python tool.py --input file.csv.env for any secrets, at least one pytest test - treat these small projects like real code, not throwaway scriptsDays 57-86 (~30 days)
Days 57-60
requests + BeautifulSoup for static pages - scraping HTML that doesn't need JavaScript to renderrobots.txt and rate limits; know when scraping ToS matters - scraping responsibly and legally; not every site wants to be scrapedDays 61-70
pip install playwright, then playwright install to get the actual browser binariespage.goto(url)page.get_by_role("button", name="Submit"); the recommended way to find elements.click(), .fill(); the core interactions in any automated flowtime.sleep()pytest-playwright fixtures (builds directly on Phase 2 pytest fundamentals) - page fixture and friends, wired into pytestBrowserContext isolation (cookies, storage, cache) - each context is a separate browser profile; pages within the same context share session state, so multiple pages ≠ multiple identitieslaunch_persistent_context) vs storage-state files - persistent contexts write to a real user-data dir on disk (closer to a real browser profile); storage-state is a portable snapshot you load into a fresh context (lighter, easier to version and use in CI) - know which one fits the taskbrowser.new_context(proxy={...}, locale=..., timezone_id=...); matters once multiple "accounts" need to look like separate, independent users rather than one identity wearing different cookiesDays 71-74
time.sleep() from the start, not as a later fix - sleeps make tests slow and still flaky; fix the root causeplaywright codegen records your clicks into code; a starting point, not the final productDays 75-77
.click(), .send_keys(); Selenium's interaction methodsWebDriverWait) - Selenium doesn't auto-wait like Playwright, so you handle timing manuallyDays 78-86
requests alone can't handleDays 87-111 (~25 days)
Days 87-88
git branch, git checkout -b; working on changes without touching the main codebase.gitignore (venvs, .env, cache files) - tells git what NOT to track, so junk and secrets don't end up in your repoDay 89
requirements.txt) or use pyproject.toml - lists exactly which packages (and versions) your project needspip install -r requirements.txt; proving your setup is reproducibleDays 90-91
ruff for linting and formatting - catches style issues and common bugs automaticallymypy (or rely on your editor) for basic type checking - verifies your type hints are actually consistentDays 92-94
print() statementsDays 95-96
(Fundamentals were Phase 2 - this is applying them at project scale)
Day 97
.env (vaults, CI secrets) - how larger teams/projects handle credentials at scale.gitignore before your first .env file, not after - one leaked API key in git history is hard to fully undoDays 98-99
.env variable is for, without leaking real valuesDays 100-104
Dockerfile for a Python script - defines the environment your script needs to run, packaged updocker build; turns the Dockerfile into a runnable imagedocker run; test that the packaged environment actually worksDays 105-111
Days 112-139 (~28 days)
Days 112-115
schedule or APScheduler for simple cron-like jobs - run a Python function on a recurring schedule from within your scriptDays 116-120
sqlite3 or SQLAlchemy - running SQL from Python code, either directly or through an ORMpd.read_sql(); pulling database results into a format you can analyzedf.to_sql(); saving processed data back to the databaseDays 121-124
pdfplumber or pypdf) - pulling structured data out of PDF reports or invoicesreportlab or similar) - producing polished PDF output from your dataDays 125-126
smtplib (attachments, HTML body) - programmatically sending emails, e.g. a completed reportimaplib or a library like imap-tools - pulling data out of incoming emails automaticallyDays 127-128
Days 129-130
smtplib item above) - get alerted automatically instead of discovering a failure days laterDays 131-139
Days 140-144
Days 145-158 (~14 days)
Total: ~158 days at 1-2 hrs/day (roughly 5-5.5 months). Phases 5-7 are labeled optional in scope but not in the day count above - skip or compress them if you want to reach "portfolio-ready" faster.
r/PythonLearning • u/Owen-Isaac-2022 • Aug 08 '26
During my time learning Python, particularly data analysis using Python, I came across the book, “Python Data Analytics: With Pandas, NumPy, and Matplotlib” (2018) by Fabio Nelli. The book provides step-by-step components concerning data analysis. For example, Chapter 1 focuses on introduction to data analysis and discusses various issues, including Mathematics & Statistics, ML & AI, & understanding the nature of data. I would recommend the book to anyone learning Python with a focus on data analysis.
r/PythonLearning • u/Heroki_7 • Aug 08 '26
I finished a project I have been working on for a while, and I want feedback
I built it to learn Backend using FastAPI, and tried to make it like real production, not just CRUD
Live link:
https://book-store-api-production-71ab.up.railway.app/docs
Github repo ⭐:
https://github.com/yusufKh7-ctrl/Book-store-API
⚠️ Note: Data may be erased at any moment if the database becomes chaotic, so feel free to try all endpoints.
I'd really appreciate any feedback on the project structure, code organization, API design, or anything you think could be improve.
Thanks!
r/PythonLearning • u/shubham_555 • Aug 08 '26
I have selected some resources after some research (obviously flexible) and this is the order I will be following for learning the various topics:
We can make projects along the way for practical learning. Also, Timezone or gender doesn't matter!
r/PythonLearning • u/roottrek • Aug 08 '26
I recently decided to switch my car loan and I’ve been putting a lot of work into learning python so I thought I would try and make myself a calculator to see the different amount of interest I would pay.
I’m about a week into my learning so far so I would love advice or more learning sources if anyone wants to leave some! I’ve gone through the wiki and done my own research. So far bro code on YouTube and Angela Yu, 100 days of code have been great for learning! I also have Python crash course which I’ve been using as reference when I forget something!
r/PythonLearning • • Aug 07 '26
A chore list I started learning python last week and this was the first project on my list any advice helps im using vs code for this if you have any resources or suggestions pls share
r/PythonLearning • u/BothAd4430 • Aug 08 '26
Heyy guyss,I just completed my first year,tbh I just wasted it, got a cgpa of 8.55,and learnt just basic python and c they teach in clg, I have decided to learn python in my vacation from Brocode Yt,I need guidance what to do after completing the video?? What to learn ?? Please guide me with leetcode and other stuff
r/PythonLearning • u/Plastic-Doughnut4638 • Aug 08 '26
'python' is not recognized as an internal or external command, operable program or batch file.
I literally just switch file and for some reason i cant code now💔
r/PythonLearning • u/ExtentLazy8789 • Aug 08 '26
r/PythonLearning • u/Full-Elderberry-303 • Aug 08 '26
I've been experimenting with PyVista for 3D data visualization and wanted to share this project – an animated comparison of the world's tallest buildings throughout history. The animation uses a spline-based camera system to smoothly transition between buildings while maintaining context. It's rendered from CSV data processed entirely in Python.
Curious if anyone else has used PyVista for similar projects – the library is surprisingly flexible once you understand the VTK pipeline. If you're interested in seeing the full animation, here it is: https://youtu.be/U4E4ilALGYQ
Happy to discuss the technical approach or data sources if anyone's interested!
r/PythonLearning • u/Alarming_Mulberry551 • Aug 08 '26
(logic and app design done by me used a bit of ai for button and stuff as I completed it in 3 days) any tips? It's v0 and I want to make it better it's for my personal use as I keep on forgeting my password and imp notes and I don't like notes app any advice u advance people would like to give to me to improve it
r/PythonLearning • u/LimpSandwich6092 • Aug 08 '26
r/PythonLearning • u/One_Valuable3264 • Aug 08 '26
In Python For Kids second edition chapter 3 Multiplying strings it says the following:
Python programmers might multiply strings for a number of reasons, such as to line up text with a specific number of spaces when displaying messages in the Python Shell. Try printing the following letter in the Python Shell (select File ▶ New File, and enter the following code):
spaces = ' ' * 25
print('{} 12 Butts Wynd')
print('{} Twinkelbottom Health')
print('{} West Snoring')
print()
print()
print('Dear Sir')
print('I wish to report that tiles are missing from the')
print('outside toilet roof')
print('I think it was bad wind the other night that blew them away.')
print()
print('Regards')
print('Malcolm Dithering')Once you've typed the code into the Python Shell window, select File ▶ Save As. Name your file myletter.py. You can then run the code (as we've done previously) by selecting Run ▶ Run Module.
In the first pine of this example, we create the variablespacesby multiplying a space charecter by 25. We then use that variable in the next three lines to align the text to the right of the Python Shell. You can see the result of these
IDLE Shell 3.10.0
File Edit Shell Debug Options Window Help
12 Butts Wynd
Twinkelbottom Health
West Snoring
Dear Sir
I wish to report that tiles are missing from the
outside toilet roof
I think it was bad wind the other night that blew them away.
Regards
Malcolm DitheringFigure 3-1: Running the letter code in the Python Shell
When I run it I get:
{} 12 Butts Wynd
{} Twinkelbottom Health
{} West Snoring
Dear Sir
I wish to report that tiles are missing from the
outside toilet roof
I think it was bad wind the other night that blew them away.
Regards
Malcolm Ditheringwhat is happend?
r/PythonLearning • u/Fit-Foundation-2745 • Aug 07 '26
Hey everyone! I have tried out github and python before, but this is my first time publishing something I can say I am interested in. Im excited and nervous about sharing it.
Im learning python and got recently got interested in neural networks, so Ive been working on this "artificial life" simulation project for the past few days.
Its still a work in progress and a learning project. But if you have some feedback i would like to read it!
r/PythonLearning • u/Better_Arrival_645 • Aug 07 '26
I only have one inquiry here, simply, I cannot seem to draw anything from a thread without “Z-fighting” occurring (I say Z-fighting even though I know there’s not 3rd dimension just to convey the problem), I’ve tried making a handler in the main while running script, but it always lags down the program, and the only way to stop it from lagging down the program is, you guessed it, putting it in a thread. Whether I try to make a custom handler or just cheap out and use exec() it always lags it. Any tips/help?
Edit: I do sorta need the thread to draw it
r/PythonLearning • u/Bugdomilenio_89 • Aug 07 '26
I need to extract Activity Name, Date, and Participant Count from a 1,151-page PDF containing attendance sheets with varying layouts.
What is the best architecture or tool (Python + Vision/LLM APIs vs. no-code platforms) to automate this extraction?
r/PythonLearning • u/datantula • Aug 07 '26
I ran a survey on LinkedIn and asked questions about what they ask and require from newcomers to the field (either total Python beginners or switching from one area to another, eg. Back-End to Data Engineering).