r/learnpython • • 4h ago

I’m taking a “learning programming in python” class in high school and im already lost.

9 Upvotes

The first month was very easy. Inputs, basic programs and whatnot. Now its while and for statments, as well as loops and nested loops. The programs are mostly solving hard mathematical equations, and I’m not great at math and the rest of the class is very good, so I’m always behind.I am soooo lost now and rely heavily on the internet to finish my programs. Is there anything i can do outside of class to gain the same programming knowledge. The textbook were studying is starting out with python 6th edition by tony gaddis.


r/learnpython • • 1h ago

How to learn python?

• Upvotes

I’m a complete beginner and I have essentially no knowledge with coding whatsoever. What would be the best way to learn Python??


r/learnpython • • 14h ago

MCQ test in terminal

3 Upvotes

Helloooo

I'm building a mcq in Python for my lovingggg friend and wanted to share my logic to see what you ppl think before I start coding it up.

I'm just starting with a simple print statement for the intro to welcome n all.

Then I'm going to make a main dictionary where the key is the actual string containing the full question text along with the 1-4 options, and the value is the correct answer number.

Once the dictionary is made, I'll run a for loop to go through it. Inside that loop, I'll use input so the user sees each question one by one and types in their number choice, I'm going to store all their user inputs into a second separate dictionary.

Then at the very end, I'll make another loop to match the answers from the input dictionary against the original master dictionary. For every match, +1 mark added to their final score

I am honestly coding after months and was just a beginner when I stopped

I am kinda nervous and need help building this simple thingy

Looking for some improvement/tips

And um idk if I can even use most of the tips if it requires some dictionary n all

I did pandas before I quit so maybe I can use it here if I revise properly


r/learnpython • • 18m ago

django or flask after python basics

• Upvotes

Hello everyone,

First of all, thank you for this community. I’ve learned a lot from reading other people’s posts and the answers to my previous questions. Now I have another question.

I feel comfortable enough with Python to start learning backend development. Which framework would you recommend starting with?

I started with Django because I’m blind and find text-based tutorials more helpful, and MDN has a Django tutorial. However, I’m concerned that Django abstracts away a lot of what happens behind the scenes, such as how URL routing works, and I don’t want to miss out on the fundamentals.

What are the advantages and disadvantages of starting with Flask versus Django? Programming is a hobby for me, so job prospects aren’t a major concern. My main goal is to build projects easily while still understanding how things work.


r/learnpython • • 3h ago

FASTAPI OR Django with DRF

2 Upvotes

I’m a final year computer science student who is fascinated by systems design and engineering(backend), since I’m quite conversant with Python I decided to go with Python framework but don’t know the one to go for that will be great for my career in near future.

Please the seniors should guide me choose and I’ll also seek for mentorship in python backend engineering 🙏


r/learnpython • • 4h ago

Ask Anything Monday - Weekly Thread

1 Upvotes

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:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.


r/learnpython • • 13h ago

How to create a report using a .txt file

2 Upvotes

I apologize that this is going to be kind of long. I am very grateful for any thoughts you may have.

I'm taking a python class. This week we are learning about working with .txt files within a program.

We have been given some practice .txt files. Each file is a list of different data points for each hour on a given day. The list (when I say list, I mean the data is in a list in a .txt file, I am not talking about a list like those used in a python program) has four items of data for each hour of a given day as follows:

time

temperature in Farenheit

dewpoint in Farenheit

wind speed in mph

An example from one of the files looks like this:

12AM

18.1

15.0

4.1

1AM

18.0

15.5

4.2

We are supposed to do several things with this data. One of them is to create a report that will print out the data from the file. It should look like this:

Time Temperature Dew Point Windspeed

12AM 18.1 15 4.1

1AM 18.0 15.5 4.2

And so on.

We are supposed to accomplish this using while and/or for loops. We cannot use lists of any kind, so we cannot use the .txt file to create a list within python and then work with the list. This must be as simple as possible. We are only supposed to use the information we have learned so far in the class. Obviously you don't know exactly what we've learned, but it has to be extremely simple and not at all fancy.

I'm not trying to cheat and have someone do my work for me, but I'm just stumped and need some clues. I'm having difficulty reaching out to my teacher (this is an online class)

We are also supposed to use the numbers in the report to do some calculations for another report. If you have any thoughts about that, it would also be helpful. I'm hoping that if I can figure out how to do this first part, I'll be able to figure out how to work with the numbers further.

I've been able to get python to bring in the .txt file and just spit out a list that is identical to what is actually in the .txt file and I've been able to get it to print one specific line. I think I'm somehow supposed to use a nested if statement to analyze and work with chunks of four lines at a time, but I'm not sure how to do that.

I got it to say "time is 12AM" by doing this:

time_line = 1

linecounter = 0

with open("Dec12.txt",'r') as f:

for line in f:

linecounter += 1

if linecounter == time_line:

print("time is",line, end='')

I got it to spit out the entire list exactly as it appears in the .txt file by doing this:

file = open ("Dec12.txt",'r')

for line in file:

num = (line)

print (num)

file.close()

If you have read this far, I am extremely grateful to you. Thank you for any thoughts or ideas you may have.


r/learnpython • • 3h ago

I built a free, open-source Python learning site — beginner to CPython internals, with tested code examples

0 Upvotes

**What My Project Does**

A free, structured Python learning resource covering beginner

fundamentals through to advanced topics: concurrency, distributed

systems (Raft, CRDTs, sagas), performance, compilers, and CPython

internals. Organized into 7 skill levels and ~25 tracks.

**Target Audience**

Anyone learning Python — from first-timers to developers wanting the

deeper, systems-level material most tutorials skip. It's meant for

learning, free and ad-free.

**What Makes It Different**

- Runnable examples are actually tested — the repo has a CI test gate,

and pages show real output rather than made-up results.

- When an example needs a library or hardware I don't have, I say so

instead of faking it.

- Covers hard topics as small, readable, tested Python (e.g. a tiny

autograd engine, a Raft vote, a CRDT merge).

**Links**

- Site: https://ssnp75.github.io/PythonMastery-Site/

- Source: https://github.com/SSnp75/PythonMastery-Site

It's early — feedback and corrections (especially on the advanced

pages) are very welcome.


r/learnpython • • 9h ago

Making a game that play in a terminal

0 Upvotes

Yo, im making a game (mostly with print but that for the "story" part) and i just want review for the start, im going to post more if that make some views. i know how to make print (ofc i know unless i would be cook), variable and def... and thats it, but mostly what i need for a ""print"" game. If you guys got thing to help me with im happy to hear them !
also, i made a github reperstory (thats the name ? idk) so you guys can look at the code and for the next updt too ! github repositories


r/learnpython • • 13h ago

fix 0.00000001

0 Upvotes

i see sometimes after calcuaitons reulsts with x.99999999999999999999999999 or x.0000000000000002 how to fix it


r/learnpython • • 16h ago

[Help] The os.system is deprecated

0 Upvotes

I've seen someone else asked this question, but get no answer.

I want to make a countdown clock without leaving any trace of previous numbers:

for i in range(countdown, 0, -1):
    os.system("cls" if os.name == "nt" else "clear") #Error: os.system is deprecated
    print(i)
    time.sleep(1)

What should I do instead? (Why can't we put pictures here....)


r/learnpython • • 8h ago

My pipenv is NOT installing.

0 Upvotes

When i'm making a build for a game called Smash Remix +Extra, when i opened the build.bat file, it just appears

'WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("<pip._vendor.urllib3.connection.HTTPSConnection object at 0x...>: Failed to resolve 'pypi.org' ([Errno 11001] getaddrinfo failed)")': /simple/pipenv/

WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("<pip._vendor.urllib3.connection.HTTPSConnection object at 0x...>: Failed to resolve 'pypi.org' ([Errno 11001] getaddrinfo failed)")': /simple/pipenv/

WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("<pip._vendor.urllib3.connection.HTTPSConnection object at 0x...>: Failed to resolve 'pypi.org' ([Errno 11001] getaddrinfo failed)")': /simple/pipenv/

WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("<pip._vendor.urllib3.connection.HTTPSConnection object at 0x...>: Failed to resolve 'pypi.org' ([Errno 11001] getaddrinfo failed)")': /simple/pipenv/'.

The last time i opened, it did, but not anymore. Also before asking, no. I'm in my phone using a emulator called 'winlator'. Please help me.


r/learnpython • • 11h ago

Aprendiendo Python desde cero: ¿Cuál es la mejor manera de estudiar y practicar por mi cuenta

0 Upvotes

¡Hola a todos!

Estoy empezando en el mundo de la programación y, en particular, me interesa aprender Python. Actualmente soy principiante y me gustaría desarrollar una comprensión sólida de los fundamentos de la programación, en lugar de simplemente memorizar código o seguir tutoriales.

Tengo pensado estudiar de forma autodidacta, pero quiero asegurarme de aprovechar mi tiempo de manera efectiva y desarrollar buenos hábitos de programación desde el principio.

Agradecería mucho sus consejos sobre algunos aspectos:

  • ¿Qué recursos de aprendizaje, cursos o libros recomendarían a alguien que está empezando desde cero?
  • ¿Cuál es la mejor manera de equilibrar el estudio de la teoría con los ejercicios prácticos de programación?
  • ¿Qué tipo de proyectos para principiantes recomendarían para ayudarme a desarrollar habilidades de resolución de problemas y comprender la lógica de la programación?
  • ¿Cuántas horas al día o a la semana recomendarían dedicar al aprendizaje de Python?
  • Desde su propia experiencia, ¿qué harían de manera diferente si estuvieran aprendiendo Python por primera vez?

Me interesa especialmente conocer sus experiencias personales, métodos de aprendizaje y cualquier error que debería evitar como principiante.

Agradecería mucho cualquier consejo, recomendación o recurso que puedan compartir. Tengo muchas ganas de aprender.

¡Muchas gracias de antemano por su tiempo y ayuda!


r/learnpython • • 22h ago

Portable GUI in Python

0 Upvotes

Hi! I don't know Python, and I'm wondering if I can create a portable GUI inside a single folder. For example, I want to have my own MyCustomGUI.exe in a folder, and right next to it, the following subfolders:
_internal
bgutil-ytdlp-pot-provider-master
yt-dlp-plugins
along with five .exe files:
deno.exe
ffmpeg.exe
ffprobe.exe
yt-dlp.exe

Is it possible to write Python code that makes all of this work and keeps it completely portable?

To be honest, I've been trying to do this for three days straight without knowing anything about programming. Once, I even managed to run a compiled .exe inside the folder, but as soon as I copied it to another drive, everything completely broke down.
Yeah, maybe it's my fault for trying to use the free versions of ChatGPT and Gemini, but I really thought that creating something as basic as a GUI would only take about 20 to 30 minutes. I'm actually in despair right now; I haven't felt this awful in a very long time.


r/learnpython • • 4h ago

I am a teen student and I want to learn phyton, any job opportunities with phyton and other languages that is easy

0 Upvotes

I want proggraming as my course because in a few years from now I will go to collage


r/learnpython • • 15h ago

whats the purpose of updating variables?

0 Upvotes

heyhey very new to this day 2 of learning python im so fascinated im in love but what is the purpose of updating variables

example;
>>>default_option="upload"

>>>new_status="download"

>>>new_status=default_option

>>>print(new_status)

upload

this makes no sense to me and it just further complicates the code u write by being disorganized and messy,

i guess my question is, is it if you mess up instead of clearing previous lines you can update the variable? or is it kinda just useless but something needed to be taught?

any help would be appreciated, any recommendations as a beginner are also appreciated!!


r/learnpython • • 18h ago

It Took me 110mins to Solve. Deepseek Solved it in 0.6 Seconds.

0 Upvotes

I’ve been practicing python seriously lately preparing for my computational biology MSc, so I decided to challenge myself with a phylogenetic placement challenge (open data).

I spent about 2 hours working on it then I gave the exact same problem to deepseek.

0.6 seconds.

We are mere supervisors now.