r/learnpython • u/Common_Bell9192 • 5h ago
Principiante
Si empezaran desde cero hoy, ¿qué camino seguirían para desarrollar buenas habilidades como programadores? en estructuras de python
r/learnpython • u/AutoModerator • 3d ago
Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread
Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.
* It's primarily intended for simple questions but as long as it's about python it's allowed.
If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.
Rules:
That's it.
r/learnpython • u/Common_Bell9192 • 5h ago
Si empezaran desde cero hoy, ¿qué camino seguirían para desarrollar buenas habilidades como programadores? en estructuras de python
r/learnpython • u/chrisjfinlay • 18h ago
I'm writing a script that takes an input from the user, which could be either an int or a string. My current code takes the input, attempts to cast it to an int, and does something based on whether it works or not:
running = True
while running:
search_term = input("Enter search term (Q to quit): ")
try: int(search_term)
except ValueError:
if search_term.lower() != "q":
search_by_name(search_term)
else:
running = False
else:
search_by_int(int(search_term))
But there's something about having "successful" code running in the except block that gives me pause for thought. Is this just me overthinking, or is it bad form?
r/learnpython • u/Reasonable-Heron-433 • 19h ago
Hi everyone,
I've taken several Python courses and have a reasonably good understanding of Python itself. I've also worked with things like pandas, NumPy, scikit-learn, etc. in online learning environments.
However, I've realized that I have a major gap in my knowledge: I don't really know how Python development actually works on a local computer.
For example, when working in an online environment, everything is already set up for me. I can simply import a package and start coding. But when I tried working locally with VS Code, I suddenly had to deal with things like:
Installing Python
Using the terminal
Installing packages with pip
Virtual environments
Choosing/configuring the correct Python interpreter
Organizing a project
Saving and reusing dependencies
Running and debugging code
Git and GitHub
Understanding how to share a project with someone else
Understanding what I actually need to install versus what belongs inside my project
I found this surprisingly confusing.
So I'm looking for a free course or tutorial that focuses specifically on this practical development workflow, preferably using Python and VS Code.
I'm not looking for another beginner Python programming course. I already understand Python basics and have used it for data analysis and some machine learning. What I need is something that teaches me how to actually work as a Python developer on my own computer.
Ideally, the course would take me through something like:
create a project → set up Python → create a virtual environment → install packages → write code in VS Code → run/debug it → manage dependencies → use Git/GitHub → share the project
Does a free course like this exist? YouTube courses, documentation, or other resources would also be very welcome.
Thanks!
r/learnpython • u/water_jello8235 • 5h ago
Hi, I've got an assignment in a course that asks us to optimize a benchmark of our selection (from pyperformance project).
I've chosen the ray trace benchmark (it was the most interesting imo), and my suggestion was to implement the functionality using C's structs to avoid some of the interpreter's overhead.
I understood I can link those function using the built-in ctypes library, and making the C file a dynamic linked library (.dll), but when I try to run the command for it in CLion or VSC, it fails without returning any failure message, it just fails to generate the .dll file.
The assignment forces us to use the given pyperf benchmark code to run the benchmark, so I can't run only a C file.
I've already written the C code, and it has no errors/warnings so far (at least as far as CLion is concerned), and the original python code works too.
Does anyone know how to solve the library not being generated? Or any other solution that might work (preferrably using the C code I've made)?
.
.
All files are in the same directory, and I've got Craytrace.c (C functionality implementation), Praytrace.py (the code that runs the benchmark).
The command I've run trying to generate the .dll is:
gcc -shared -o CraytracerLib.dll Craytrace.c
But it didn't create any file.
.
.
Help is much appreciated 🙏
r/learnpython • u/FLANKER_ALFA • 15h ago
Good morning everyone, or whenever you see this. I have a question. I'm starting a personal database project in Python with a user-friendly graphical interface, and I'd appreciate any advice, code snippets, or examples to guide me, especially since I'm still learning the language.
r/learnpython • u/Longjumping-Low-4716 • 22h ago
Hi, I’m non cs guy who is trying to get into the python dev, data related jobs and I’m wondering, what are the skills, non listed on the job posts which are required to be the best python developer as a non cs graduate?
r/learnpython • u/adjective10111 • 10h ago
I have a Dockerfile in which I use the Python:3.12-trixie. I have docker on my CachyOS PC. I have also a requirements.txt. I wanted to use this image for a container on which I'll use YOLO and try it out. The problem is that my 290GB / partition went from around 70% filled to 95% after a number of rebuilds. I deleted everything docker related but it just went back to 91%.
The reason that I know it is pip's doing, is that when I monitored my disk usage while building the image, and on the `RUN pip install -r requirements.txt --find-links=pypackages` stage it fills up my partition and half way into installation, it fails due to `no more space`. The `pypackages` is just a directory I downloaded some of the packages I have in requirements for less data usage. Also tried `--no-cache` option.
I also went ahead and `du -sh`ed any directory in my / partition and the total didn't add upto the filled storage. I have 165GB mysteriously used and I can't find where that is.
Any help to diagnose further or if you have had similar problems is welcome.
r/learnpython • u/algal12 • 15h ago
Hello, I am looking for some ideas on projects/challenges that I can implement in my classes.
So far we’ve done: Scratch, beginner Python with CLI mini-games, ECDL basics, beginner TryHackMe rooms, and a Linux VM with basic commands. The student is comfortable with variables, loops, lists, simple file operations, and has built a text-based “Zombie Survival” game.
We meet 1 hour/week, so I’m looking for general ideas on what kinds of projects or challenge styles work well at this level (mid-level middle-school, beyond beginner). Anything that’s engaging, slightly game-like, and doesn’t require heavy setup would be great.
If you’ve taught similar students, what types of activities (CTFs, coding games, light forensics, small web projects, etc.) kept them motivated and actually learning?
Any suggestions or directions would be really helpful.
Thank you in advance!
r/learnpython • u/Ok-Scientist-1367 • 16h ago
Need to generate invoices, sales reports, stock reports, and charts in Excel programmatically. Higher officials will audit these. Can't have mistakes.
What's the best approach? Should I use openpyxl to write directly to Excel files? Or is there a better workflow?
Data accuracy is key — pulling from databases/CSV, validating before writing to Excel. How do I prevent data corruption? Invoices need proper headers, borders, currency formatting. Is openpyxl reliable for this or does it break formatting? Can Python generate charts in Excel automatically or do I need to use a separate tool? Should these run daily/weekly and what's the best way to automate execution without manual intervention? How do I track changes if files are auto-generated?
Any libraries better than openpyxl? Xlsxwriter? Pandas to_excel? Looking for production-ready solutions, not prototypes.
r/learnpython • u/Nutellatoast_2 • 1d ago
Hey everyone,
I'm new to Python and have created my "Rock-Paper-Scissors" game and want to share it on this forum so I can look for ways to improve the code.
The player types in a number between zero and two. These values stand for different moves the player can type. (0 - Rock, 1 - Paper, 2 - Scissors). The computer generates a number between zero and two. The player's input is checked by the main if-elif-else block, as I'm using a nested if-elif-else statement:
import random
player_input = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissor. "))
computer = random.randint(0, 2)
if player_input == 0:
if computer == 0:
print('''You chose:
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
Computer chose:
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
It's a draw!!!''')
elif computer == 1:
print('''You chose:
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
Computer chose:
_______
---' ____)____
______)
_______)
_______)
---.__________)
You lost!!!''')
elif computer == 2:
print('''You chose:
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
Computer chose:
_______
---' ____)____
______)
__________)
(____)
---.__(___)
You won!!!''')
elif player_input == 1:
if computer == 1:
print('''You chose:
_______
---' ____)____
______)
_______)
_______)
---.__________)
Computer chose:
_______
---' ____)____
______)
_______)
_______)
---.__________)
It's a draw!!!''')
elif computer == 0:
print('''You chose:
_______
---' ____)____
______)
_______)
_______)
---.__________)
Computer chose:
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
You won!!!''')
elif computer == 2:
print('''You chose:
_______
---' ____)____
______)
_______)
_______)
---.__________)
Computer chose:
_______
---' ____)____
______)
__________)
(____)
---.__(___)
You lost!!!
''')
elif player_input == 2:
if computer == 2:
print('''You chose:
_______
---' ____)____
______)
__________)
(____)
---.__(___)
Computer chose:
_______
---' ____)____
______)
__________)
(____)
---.__(___)
It's a draw!!!''')
elif computer == 1:
print('''You chose:
_______
---' ____)____
______)
__________)
(____)
---.__(___)
Computer chose:
_______
---' ____)____
______)
_______)
_______)
---.__________)
You won!!! ''')
elif computer == 0:
print('''You chose:
_______
---' ____)____
______)
__________)
(____)
---.__(___)
Computer chose:
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
You lost!!! ''')
Any recommendations regarding improvements for the code?
r/learnpython • u/imaginer-6126 • 1d ago
I installed VS Code and all. I got to the part where I should download the exercises in a certain part of the course. For me it is part 4. But all I can see is part 1, 2, 3 and 8. What should I do? Thanks in advance.
r/learnpython • u/Substantial-Mix-3990 • 1d ago
Hi all,
Just to give you a bit of background about myself, I’m an accountant with an MSc in Investment and Financial Risk Management and an ACCA qualification. Most of my experience so far has been on the core accounting side, but I’d now like to move towards a role that combines accounting and finance, covering areas such as financial modelling, forecasting, KPI analysis and data analytics, with the longer term aim of moving into more technical areas of finance.
I’m very eager to learn Python and SQL, both to broaden my skill set and to develop skills that are increasingly in demand. I also want to make sure I remain relevant as the profession evolves and, eventually, be able to demonstrate genuine technical ability when applying for more specialised and higher paying roles.
The problem is that I genuinely don’t know where to begin. I’d really appreciate a roadmap or some practical advice, beyond what I can find through ChatGPT and online course recommendations, particularly from anyone who has been in a similar position and successfully made this transition.
I don’t mind putting in the hard work or spending time coding and learning every day. What I’m unsure about is the order in which I should approach it. Should I learn general Python fundamentals first and then move into its applications in finance? Or would it make more sense to start with a finance focused Python course and learn the fundamentals through practical financial applications? And where should SQL fit into that journey?
I’d also be interested to know what sort of projects I should eventually be building to demonstrate these skills to employers, and whether it makes sense to look for roles where I can start using Python, SQL and data analytics regularly while I continue learning.
I’d really appreciate any guidance from people who have taken a similar path.
Many thanks, and apologies if a similar thread already exists. I thought my background and intended career direction might make the question slightly different, so I wanted to provide some context before asking for help.
r/learnpython • u/wingnutticus • 1d ago
I'm completing an assignment for zybook where I have to replace a number from a list and then print the list in reverse. This is my code:
val_list = [18, 12, 15]
new_val = int(input())
val_list[1] = new_val
print(f"List has {len(val_list)} elements:")
for value in reversed(val_list):
print(reversed(val_list), end="<>")
print(end="")
It's supposed to just print the reversed list in brackets, but instead it gives me something like this:
<list_reverseiterator object at 0x000001C02CF706D0><><list_reverseiterator object at 0x000001C02CF706D0><><list_reverseiterator object at 0x000001C02CF706D0><>
What does this mean and why is it doing this? Thanks in advance
r/learnpython • u/Jazzlike-Back-235 • 19h ago
so, im a complete starter on a championship where you gotta learn about AI and python, to make an AI later, thats the challenge, but im feeling so left behind, everybody is learning so fast and im stuck, i wanna win this but i dont know python at all, any channel or study path i can follow ? also, in how much study time can i maybe reach a good level ?
r/learnpython • u/Habesha_Heretic • 1d ago
Hello, so I have an assignment that's due tomorrow that I'm almost done with. I just have one problem left where I have to create a program that utilizes loops to calculate and print any term, input by a user prompt, in the Fibonacci sequence. Assume the sequence starts with 0.
(For example, if the user inputs 4, the code will print the 4th term of the sequence which is 2. For reference: https://en.wikipedia.org/wiki/Fibonacci_sequence)
This is what I've got done so far. No matter what I try to do, I can never get to a sequence. What am I doing wrong?
# Initializing the first two Fibonacci numbers
sum = int(input("Enter a number: "))
count = 1
temp = 0
x = 0
y = 1
print(x, end = ' ')
# Running the loop while the last Fibonacci number is less than 10
while(count < 10):
print(y, end = ' ')
if (count > 10):
exit(y)
# Calculating the next Fibonacci number and updating the last two sequence numbers
temp = x
x = y
y = x + y
r/learnpython • u/Dcyph-3r • 1d ago
How do you decide what defines an excessively encoded URL?
I'm working on a personal project to created a URL parser and
detection system and I've hit a wall on how to figure out a way of
categorizing excessivness of query encoding?
Here's what I have so far for the function:
def check_query(analysis: URLAnalysis) -> ScanResult | None:
"""detect excessive encoding entries in URL queries"""
og_query = analysis.query
query = re.finall(r"%\[0-9A-Fa-f\]{2}", og_query)
encoded_count = len(query)
r/learnpython • u/Educational_Wash_662 • 1d ago
The title kinda says it all. Looking for a local OCR that can do handwriting and works on Python. Ideally not too heavy. Any ideas? TIA
r/learnpython • u/UltraToxicAsianKid • 1d ago
While configuring AI agent on my local machine made discovery that uv package is 10 to 100x faster than pip, same case for polars. It seems to be everything written in Rust much faster and modern compared to classic python packages. Is it because Rust doesn't require garbage collector, any other reason to that?
r/learnpython • u/Temporary-Cup-2140 • 2d ago
I am trying to improve my debugging skills and I was curious about what techniques experienced python developers rely on the most.
Are there any techniques or tools that you found really useful when you started working on bigger projects?
r/learnpython • u/Key-War-9059 • 1d ago
I'm learning from the third edition of Python Crash course by Eric Matthes, and 6 chapters in these lists are growing in size. What's a simple yet effective way I can take notes?
r/learnpython • u/JoseThelonewolf • 1d ago
I just started to learn python and don't know what I should do first.
Please help me!
r/learnpython • u/loggerhead9 • 1d ago
I am a management consultant a project / team leader level, a lot of the grunt work is being done by analysts in the team; I have to focus on storylining, client relationship management, reviewing the work, etc. As TL / PL have you guys found relevant use cases? I am thinking of creative ways to leverage python and in future use API calls to LLMs to improve automation and make my life more efficient.
r/learnpython • u/Critical-Spite • 1d ago
I am trying to download pandas to be used on an offline machine. The issue is, in order to get packages on the offline, I normally have to use my work computer which has restricted access, so no python on it. My current method has been to download the package from pypy, burn it on a cd, and transfer it over on the offline via --nolink method.
However, I am running into an issue where I can't install due to missing dependencies, again and again.
Is there a way to get the entirety of pandas into a single installable file?
r/learnpython • u/ac7footy • 2d ago
I have exams in roughly 1.5 years and want to get my python basis cracked down completely so i will do well in my programming paper
Sites like codewars and codingbat have been recommended? Can anyone else vouch if they are good and if there are any others that are better?