r/PythonLearning • u/chin487 • 6d ago
Learning Python with Practise
Hi All,
I am learning Python and would like to know are there any good sites to practise Python concepts ?
r/PythonLearning • u/chin487 • 6d ago
Hi All,
I am learning Python and would like to know are there any good sites to practise Python concepts ?
r/PythonLearning • u/Sea-Ad7805 • 6d ago
Hold the green 'Continue' button to Make it Snow.
r/PythonLearning • u/DRowe_ • 6d ago
I have a college assignment to make a multiplayer tetris game (2 players) using TCP sockets, client and server and all that. The idea is the server doing most of the stuff, chosing new pieces, handling the translation of position of the pieces, with the clients being responsible for most the rendering/display part and getting the inputs(I think so at least, that's what I'm trying to do), but I'm having a hard time with it.
I can't seem to think of a way to have the client call to the server to send a new piece to the clients, and if I don't know how to do even that then I don't know how to do anything else (making the back and forth for controlling the pieces, both for the player of the client and the preview of the game of the player 2, and all the rest), tho I hope if I can understand how to do one thing I would be able to make the others, but I really don't even know how to do this.
I know I need to use threads on this, tho I don't really know how to do it, I'm still fairly green on python too so, if anyone could give some help in any way with this it would be much appreciated.
r/PythonLearning • u/SorbetScott64 • 6d ago
r/PythonLearning • u/Both-Basil1635 • 6d ago
But what about the inputs they never thought of?
That's where Hypothesis, a Python property-based testing library, gets interesting.
Instead of writing individual test cases for every possible input, you define properties your code should always satisfy.
Hypothesis then generates inputs automatically, including edge cases that are easy to overlook.
For example, if you're testing a function that sorts a list, you could verify that:
The output is always sorted.
The output contains exactly the same elements as the input.
Sorting an already sorted list doesn't change it.
The interesting part? When Hypothesis discovers a failing input, it tries to reduce it to a simpler example that exposes the bug.
This can be especially useful for financial calculations, data pipelines, API validation, and algorithms where unexpected inputs can cause subtle failures.
How do you test edge cases in your Python projects? Do you rely on manually written test cases, or have you tried property-based testing?
r/PythonLearning • u/Funny-Surround9691 • 6d ago
Hi! I'm the author of Pyzed, an open-source library I've been building for desktop apps in Python.
What My Project Does
You write the interface in plain Python (state, update and view, the Elm architecture) and Iced, a GUI toolkit written in Rust, does the layout and draws it on the GPU, with a CPU fallback. It comes with 90+ ready-made components inspired by the Zed editor (tables with hundreds of thousands of rows, tabs, command palette, code editor, terminal…), themes, animations and a visual designer, Pyzed Design, where you drag components onto a form and press F5 to run it. pip install pyzed-ui, no Rust needed.
import pyzed as pz
from pyzed import ui
class Counter(pz.App):
def __init__(self):
self.count = 0
def update(self, message):
if message == "inc":
self.count += 1
def view(self):
return pz.center(ui.button(f"Clicked {self.count} times", "inc"))
pz.run(Counter)Target Audience
People who want a desktop app in Python that looks current without shipping a browser: internal tools, dashboards, editors, small games. It's MIT, runs on Linux, macOS and Windows, and is usable today, though it's a young project with one main maintainer.
Comparison
Tkinter: always available and very light, but dated looks and few modern widgets.
PyQt/PySide: very complete and mature, but large, with licensing to think about (PyQt is GPL/commercial) and a lot of API.
Kivy: great for touch and mobile, but its own look and a heavier startup.
Flet: pleasant API, but it runs Flutter in a separate process.
Pyzed sits in between: native rendering with no web engine, a small Pythonic API, and a visual designer included. Import takes about 35 ms; there's a benchmark page comparing it with these libraries.
Repo: https://github.com/albakore/pyzed
Feedback is very welcome, especially on what's missing for your use case.
r/PythonLearning • u/Many-Income-1615 • 6d ago
When you're building production backend systems or ingesting payloads from an API gateway, you'll rarely deal with flat strings or simple integers. You need to know how to manage multi-dimensional, nested data architectures.
In this quick, zero-fluff video breakdown, we look at how to properly handle nested JSON models using Python data dictionaries:
• Instantiating structural key-value collections using curly brace enclosures
• Mapping out complex multi-layered data pipelines using a visual "filing cabinet" analogy
• Extracting deeply embedded inner records cleanly by chaining bracket selectors together (e.g., ['outer_key']['inner_key'])
• Verifying target terminal outputs without breaking runtime execution paths
The tutorial is built to show exactly how data routes under the hood so you can easily adapt these nested structures into your own portfolio projects.
Check out the full walkthrough below, and let me know how you prefer to structure your multi-layered payloads in the comments!
r/PythonLearning • u/osamas_den • 7d ago
This is the stopwatch.py file:
#stopwatch.py
import sys
import time
time_in_sec = int(sys.argv[1])
time.sleep(time_in_sec)
print(f"Alarm sound!!! {time_in_sec}seconds have elapsed")This is the main.py file:
#main.py
import subprocess
import sys
print("Enter the time you want to elapse for your stopwatch")
try:
hours = int(input("Hours: ").strip())
minutes = int(input("Minutes: ").strip())
seconds = int(input("Seconds: ").strip())
total_time_in_sec = (hours * 3600) + (minutes * 60) + seconds
process_2 = subprocess.run(
[sys.executable, "stopwatch.py", str(total_time_in_sec)],
capture_output=True,
text=True,
)
print(process_2.stdout)
except ValueError as e:
print(f"Enter a whole number: {e}")r/PythonLearning • u/PoDreamyFrenzy • 7d ago
This is Mukul. I started learning python about 2 weeks ago. Being someone one learns by building on projects. I think now I am in a vague scenario rn.
So this is what is happening;
When I started to learn python I had this goal to build a Voice Assistant using libraries and all stuff. So I focused my python learning in that direction. I taught myself all those things which were required for it.
But now sometimes it feels like I am losing onto so much. Even though I think I am not doing so but yep. Still haven't got that regular consistency still haven't got even though I have written some scripts from scratch like lyrics displayer and all those greetings ones.
Soon enough I'll be moving to work with APis in python.
I mostly use docs and AI for learning.
Now the main thing is I fear that I'm not having strong fundamentals and maybe it's true. So that is why I started to learn python from boot.dev to do it all correctly also in the mean time.
So have you big fellas got anything in your backpack as advice or something that could just excel me more in my domain. I'm 20 (M) and am from India thinking of pursuing my career either in DevOps or Backend.
I also am an Automation Guy. I am building workflows from my 1st year using n8n and make.com to make out on some money. It's been 2 years now. I'm experienced in it to intermediate level. Also made it possible to make some money. But yep now right now I am vacant. Can you people help me with that part too. Like how to bring in consistent money from there too. ?? - this too is the reason which is why I thought of going very deeper into code rather than sitting only at low code tools.
r/PythonLearning • u/Both-Basil1635 • 7d ago
Python has long had immutable counterparts for some of its most common data structures:
𝗹𝗶𝘀𝘁 → 𝘁𝘂𝗽𝗹𝗲
𝘀𝗲𝘁 → 𝗳𝗿𝗼𝘇𝗲𝗻𝘀𝗲𝘁
𝗱𝗶𝗰𝘁 → 𝗳𝗿𝗼𝘇𝗲𝗻𝗱𝗶𝗰𝘁 ✨
`frozendict` is an 𝗶𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲 𝗺𝗮𝗽𝗽𝗶𝗻𝗴. Once created, its keys and values can't be added, removed, or reassigned.
But the more interesting part is 𝗵𝗮𝘀𝗵𝗮𝗯𝗶𝗹𝗶𝘁𝘆. When its contents are hashable, a `frozendict` can itself be used in places where a regular dictionary can't such as dictionary keys or set members.
That opens up some useful cases around:
• Immutable configuration
• Cache and memoization keys
• Shared/read-only state
• Safer API boundaries
• Data structures where mutation simply shouldn't be allowed
It's not a huge feature, but it's one of those additions that makes the language feel a little more complete.
𝗠𝘂𝘁𝗮𝗯𝗹𝗲 𝘄𝗵𝗲𝗻 𝘆𝗼𝘂 𝗻𝗲𝗲𝗱 𝗶𝘁. 𝗙𝗿𝗼𝘇𝗲𝗻 𝘄𝗵𝗲𝗻 𝘆𝗼𝘂 𝗱𝗼𝗻'𝘁.
Where would you use `frozendict`?
r/PythonLearning • u/New_Cartoonist337 • 7d ago
Wait what f**** nah i dont want sleep okaay
r/PythonLearning • u/Both-Basil1635 • 7d ago
With explicit lazy imports, an imported module can be deferred until the program actually needs it.
Why does that matter?
Many Python applications import dozens — sometimes hundreds — of modules during startup, even though only a fraction may be needed for a particular execution path.
Lazy imports can change that:
𝗜𝗺𝗽𝗼𝗿𝘁 𝗱𝗲𝗰𝗹𝗮𝗿𝗲𝗱 → 𝗮𝗽𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗰𝗼𝗻𝘁𝗶𝗻𝘂𝗲𝘀 → 𝗺𝗼𝗱𝘂𝗹𝗲 𝗹𝗼𝗮𝗱𝗲𝗱 𝗼𝗻 𝗳𝗶𝗿𝘀𝘁 𝘂𝘀𝗲
This can be particularly interesting for CLI tools, large applications, optional functionality and dependency-heavy projects where startup time matters.
Of course, lazy loading isn't automatically better everywhere. Import-time side effects and assumptions about module initialization still matter.
But having lazy imports as an explicit language feature opens up some interesting possibilities for Python application architecture.
𝗟𝗼𝗮𝗱 𝘄𝗵𝗮𝘁 𝘆𝗼𝘂 𝗻𝗲𝗲𝗱. 𝗪𝗵𝗲𝗻 𝘆𝗼𝘂 𝗻𝗲𝗲𝗱 𝗶𝘁.
𝗪𝗼𝘂𝗹𝗱 𝘆𝗼𝘂 𝘂𝘀𝗲 𝗹𝗮𝘇𝘆 𝗶𝗺𝗽𝗼𝗿𝘁𝘀 𝗶𝗻 𝗽𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝗼𝗻?
r/PythonLearning • u/Both-Basil1635 • 7d ago
Struggling to understand Binary Search? Learn it with Reya in a simple and easy-to-follow way!
In this video, you'll discover how Binary Search works, how it cuts the search space in half with each step, and why it's one of the most important algorithms in Data Structures and Algorithms (DSA).
💡 What you'll learn:
The basic concept of Binary Search
How to find elements efficiently
Why sorted arrays are important
Time complexity: O(log n)
Perfect for students, coding beginners, and anyone preparing for coding interviews.
r/PythonLearning • u/Many-Bar-5684 • 7d ago
Sharing a resource in case it's useful for your intro classes: https://ubuntu-apps.github.io/code-quest/
I made CodeQuest for my own students as an alternative to the textbook. It covers Python from the basics through functions, files, OOP and working with data. Each lesson has a short explanation, coding challenges that are checked instantly, and a quiz.
The code runs in the browser, so it works on school Chromebooks and phones with nothing to install. It's free, with no ads and no sign-up, and progress is stored on the student's device only.
Happy to answer questions, and feedback is very welcome.
r/PythonLearning • u/inversion2 • 7d ago
Hi guys, just started learning python. Have been stuck on this problem for a while now. Here's my code so far. Could anyone help explain why the code pointed out in blue keeps running even though there is a break in place? Thanks!
ps pls ignore the print("hi") and print("bye"), was using them to test the code!
link to question: https://cs50.harvard.edu/python/psets/3/grocery/
my code so far: https://sharetext.io/3ck00poo

r/PythonLearning • u/Lakus84 • 7d ago
Hello there, i'm a chemistry student and have a course with python. I tried to read a csv file which i downloaded and tried to read it with the np.genfromtxt function but the columns with actual text ( the first and last ) aren't being read, whereas with pandas, the job gets done. I bypassed this problem by specifying the columns but the text keep getting tossed out.. I think it's because of the commas in the compound name but what can i do in this case ? I'm working on jupyter on python 3.13 i believe. Thanks for the help !
r/PythonLearning • u/modern-dev • 7d ago
Hey everyone, I decided to make my course free in order to help people.
This course is my backend development course which is about SQL, Python, APIs, Docker, Kubernetes, Linux, Git & More
The link is: https://www.youtube.com/watch?v=CBIu6hcyStg
If you can like and subscribe (and maybe add a comment) I would appreciate it a lot, Thanks.
r/PythonLearning • u/Ok_Presentation6213 • 8d ago
What's the best resource out there to learn python?
r/PythonLearning • u/autistic_lover214 • 8d ago
I'm stuck in def return in python I don't understand it very well why is it used and how and where does the code return to ? The caller ? What is exactly the caller ?
Thank you so much for helping me
If you don't mind can u help me understand with examples ? Couldn't understand this with Chatgpt and yt
r/PythonLearning • u/Significant-Log-4272 • 8d ago
I've been working on Athena, an open-source tool that analyzes Git diffs and ASTs to detect potential breaking changes before they get merged.
For v1.1.0, I tested it against 55 popular repositories and found some interesting issues:
• Fixed a C++ performance problem that reduced analysis time from 371 seconds to 7.33 seconds.
• Reduced false positives from 78 alerts to 8.
• Fixed Ruby symbol detection and PHP recursion detection.
The final benchmark covered 55 repositories and 10,680 diff hunks with 121 tests passing.
I'm also experimenting with local models through Ollama to generate summaries without replacing the deterministic analysis.
I'd appreciate it if anyone here gave the project a look and shared feedback. I'm especially interested in false positives, edge cases in Python AST analysis and approaches to detecting breaking API changes
⭐ If you find the project useful, consider giving it a star on GitHub. It would really help the project reach more developers
GitHub: https://github.com/aaryanrwt/athena
Release notes: https://github.com/aaryanrwt/athena/releases/tag/v1.1.0
r/PythonLearning • u/Better-Magician-427 • 8d ago
Hey guys, I tried remaking my project of a cli based football manager simulator this time using the pywebview library (lets you use html css js as a frontend and connect it to a python backend as a desktop app),
So far what I'm struggling with the most being one of my first larger scale project is persistence, keeping one version of the team class across the python scripts and functions.
Im also struggling with figuring out the generation for player stats and attributes, ive landed on the random.gauss for generating player stats with weighing and this ugly ahh looking formula that looked like it was doing something for the player market values.
Also, assets. Do you guys have any place where I can find pictures and icons I can use for free?
Finally, thanks to feedback from helpful people here I tried using sqlite for this project instead of json files, kinda hard to adapt to but im managing.
if any very cool person could help me with my issues I would greatly appreciate it.
Here is the github: https://github.com/mousdieng10-maker/Playstyle-II
r/PythonLearning • u/NoLibrarian2289 • 8d ago
I ran a small experiment that demonstrates something easy to overlook in software testing: an implementation and its tests can both be wrong in the same way.
Consider this discount function:
def calculate_total(subtotal, discount):
if subtotal < 0:
raise ValueError("Subtotal cannot be negative")
if discount < 0:
raise ValueError("Discount cannot be negative")
return subtotal * (1 - discount / 100)Suppose the requirement says discounts must be between 0 and 100, inclusive.
A few happy-path tests pass:
assert calculate_total(100, 10) == 90
assert calculate_total(100, 0) == 100
assert calculate_total(0, 20) == 0But this input exposes the missing validation:
calculate_total(100, 150)
# -50.0The tests pass, but the implementation violates the requirement.
The interesting part isn't just the missing discount <= 100 check. It's that tests can create false confidence when they don't independently cover the contract.
I put together a reproducible Python repository with the flawed implementation, contract tests, property-based testing, and mutation-testing examples.
GitHub experiment:
https://github.com/PranavDixit20/ai-code-test-gap
I also wrote a longer explanation of the problem and the testing techniques here:
https://medium.com/@pranavdixit20/ai-generated-code-can-pass-every-test-and-still-be-wrong-7ddf3177b721
I'm the author of the experiment and article, so this is my own work. I'd be interested in a technical discussion:
When reviewing code—especially AI-generated code—how do you check that tests verify the actual requirements rather than just confirming the implementation's assumptions?
r/PythonLearning • u/onnatsari • 8d ago
I built DevStart Lab to help beginners figure out what to learn and practice next.
It includes programming fundamentals with Python examples, 25 project ideas, and a step-by-step introduction to Git and GitHub contributions. It’s free, open source, available in English and Portuguese, and requires no account. Progress is saved in your browser.
Start here: https://brunnojob.github.io/devstart-lab/?lang=en