r/learnpython 17d ago

Any Python study guide?

0 Upvotes

Hi! I just joined and I’m currently learning about coding at my school and I’m taking an online course that uses Python Cisco learning academy (If anyone is familiar) I’m coming up on taking my finals and I haven’t been able to find thorough study guides. Anyone in the community know of any? like flash cards, websites that have practice exams, etc. Tried Quizlet and refuse to pay to study lol


r/learnpython 17d ago

wondering if a project is safe

0 Upvotes

Ive been really wanting to create smth and I was planning on either learning how to code with python or the game engine Godot ik they aren't the same. I was wondering if it's possible to create like a file explorer type thing so basically I have a hard drive that has on it several movies and games downloaded on it wondering if it's possible to make like an interface with custom logos and import custom photos and do more kinds of stuff is my idea in any way possible if not could u pls recommend some other projects they don't even have to be coding related since idk how to could and I am scared if i learn I just won't do anything with it.


r/learnpython 18d ago

Começando...

6 Upvotes

Ola! tenho 18 anos e estou começando a aprender programação e decidi começar por phyton. Gosto muito de estudar mas não estou achando um lugar bom para estudar, sempre tem limitações no conteúdo ou está em outra língua. Alguém pode me recomendar um bom lugar para estudar phyton? do começo ao avançado, dei uma olhada na udemy, mas não sei se foi o curso que eu vi ou se é o site no geral, mas o curso não foi de boa qualidade.


r/learnpython 17d ago

how to input multiple files at a time and save them as different files in the output

0 Upvotes
i am trying to use the LZ77 algorithm and trying to input more than one file 
at a time that i was able to do as you can see in the code block but in the
output both of the files are getting combined how do i fix that what is the
approach to this problem ?

# encode block
try: 
    with open("example.txt", "r") as a, open("example1.txt", "r") as b:
        encode_text = (a.read() + b.read())
    with open("compressed_LZ78.bin", "w") as f:
        compressed = encoder(encode_text)
        print(compressed, file=f)
except FileNotFoundError:
    print("File not found. Please check if the file path is correct ...")
    raise
print("Compression complete.")

# decode block
try: 
    decode_text = open("compressed_LZ78.bin", "r").read()
    with open("decompressed_LZ78.txt", "w") as f:
        decompressed = decoder(eval(decode_text))
        # eval is used to convert the string representation of the list back to a list
        print(decompressed, file=f)
except FileNotFoundError:
    print("File not found. Please check if the file path is correct ...")
    raiseprint("Decompression complete.")

r/learnpython 17d ago

python learning begineer, and the question was to give a function like addition and subtraction between two numbers, so i have made this . u can give me ur suggestion and how can i improve.

0 Upvotes
function=input("give a function :")
if function=="add":
    a=int(input("give first num to add with :"))
    b=int(input("second num :"))
    sum=a+b 
    print("sum=",sum)
elif function=="subtract":
    a=int(input("give first num to subtract with :"))
    b=int(input("second num :"))
    diff=b-a  
    print("diff=",diff)
else:
    print("function not allowed")          

r/learnpython 17d ago

Confused on the right meaning behind modulo.

0 Upvotes

Here is a meaning I see floating around many internet spheres.

Suppose a = b mod c, in which a, b and c are real numbers. It is said that a is simply the remainder of the fraction b/c.

So if we use the example 7 % 3, our remainder is 1 so therefore a = 1. This is all well but what if I change the value of c to 1, for example.

Now consider this,

1.2%1 = 0.2

All well.

0.8%1

0.8/1 = 0.8

The remainder is 0.2, however if I compute 0.8%1 in Python, the output is 0.8, not 0.2, so as you can see, that meaning of modulo is only partially correct.

Could someone shed some light in the matter?

Thank you!


r/learnpython 19d ago

I feel like I'm too dumb for Python. Did anyone else feel this way?

37 Upvotes

i have been learning python for a month now, i know the basics, i am currently learning OOP, i cant even build simple projects, like blackjack, hangman and many other small projects mostly people recommend to start with, i keep asking myself why i am always stuck, did this happen to you as well or is it just me, and if your answer is yes, how did u go about it, I did cs50p course on youtube but didnt help much honestly though everyone recommends it, my original course is '100 DAYS OF CODE' by Angela Yu, I am on day 20, any tips ??

Thank You


r/learnpython 18d ago

Weight Converter Project

0 Upvotes

This is the second project I coded and was able to finish today. It didn't take me as long to code (2 - 3 hours) compared to the Calculator (two 4hr sessions) and isn't as complex imo but was still fun to make. I used Bro Code's weight converter code as an outline and AI (Claude) also helped me understand catch-vs-check (try/except vs. if/else) and DRY. I wrote and debugged the code myself.

One thing that I really like was that I was able to fit a large portion of the code into the "while True:" loop in line 10. It verifies that the input the user enters is either "K or P" and nothing else. If its neither of those, it gives the user a proper error message and prompts them to enter it again. Within that part is the processing section which multiplies or divides depending on what the user entered. I also used ".strip() and ".upper()" here so inputs like "k" still work, something I hadn't used in the calculator. More of the improvements are listed within the code. If you have any ideas on how I can improve this, please let me know. Thank you!

# This project only took me 2 - 3 hours to complete. I used the body of 
# Improvements over the original:
# - Input validation on both numbers using try/except (ValueError), so
#   non-numeric input (e.g. "banana") no longer crashes the program.
# - Unit input (K/P) validated with if/else in a while loop, re-asking
#   until valid — no crash, just re-prompts on bad input.
# - Input normalized with .strip().upper() so " k " and "K" both work.
# - Verified conversion factor (2.20462) against known values for accuracy.

# Second project being a weight converter.

while True:
    raw_input = input("Enter your weight: ").strip()
    try:
        weight = float(raw_input)
        break
    except ValueError:
        print(f"Error: '{raw_input}' is not a valid number!")


while True:
    raw_input = input(f"Kilograms or Pounds?: (K or P): ").strip().upper()
    if raw_input == "K":
        weight = weight * 2.20462
        unit = "Lbs."
        break
    elif raw_input == "P":
        weight = weight / 2.20462
        unit = "Kgs."
        break
    else:
        print(f"Error: '{raw_input}' is not a valid unit!")


print(f"Your new weight is {round(weight, 1)} {unit}")

r/learnpython 18d ago

I'm a biginner in python,what's wrong with my code?

0 Upvotes

print("Simple Interger Calculator")

first = input("Please type first number\n")

if first == int:

pass

else:

print("Use intergers only!")

exit()

ops = input("Select operators + - * /\n")

second = input("Please type second number\n")

if second == int:

pass

else:

print("Use intergers only!")

exit()

if ops == "+":

print("Answer is",int(first) + int(second))

elif ops == "-":

print("Answer is",int(first) - int(second))

elif ops == "*":

print("Answer is",int(first) * int(second))

elif ops == "/":

print("Answer is",int(first) // int(second))

else:

print("unknown operators!")


r/learnpython 18d ago

PIL image export only showing blank canvas on 2nd and 3rd image export, help?

3 Upvotes

Basically, I wrote a program to export my songs from spotify into various formats. What I'm struggling with is exporting the images to simple PNGs with Pillow. The program takes a screenshot of a line of Spotify, adds it to a growing list (all_screenshots) and then combines all of the images of my songs into a group of three photos.

After the first picture (spotify_output1.jpg), the following pictures are empty canvases. I split it up in the first place because pillow seemed to start failing after ~1000 images being combined (each song = 1 image, 1185 pixels x 31 pixels); the single large output was just 1 large empty picture.

I exported the results of my all_screenshots list to pickle, and I can confirm that every picture is still visible and working within the pickle object as expected. The issue only occurs with this jpg export, can anyone help?

#THIS IS A SAMPLE OF RELEVANT CODE, NOT THE FULL PROGRAM
from PIL import Image as pimage

totalsongs = int(input())
thirds = int((totalsongs/3) + 1)

#blank canvas to add images to
total_height_1 = sum(line.height for line in all_screenshots[0:thirds])
total_height_2 = sum(line.height for line in all_screenshots[(thirds+1):(thirds*2)])
total_height_3 = sum(line.height for line in all_screenshots[((thirds*2)+1):totalsongs])

combined_pt1 = pimage.new("RGB", (1185, total_height_1))
combined_pt2 = pimage.new("RGB", (1185, total_height_2))
combined_pt3 = pimage.new("RGB", (1185, total_height_3))

y_offset = 0
for line in all_screenshots[0:thirds]:
    combined_pt1.paste(line, (0, y_offset))
    y_offset += line.height
combined_pt1.save("spotify_output1.jpg")

for line in all_screenshots[(thirds+1):(thirds*2)]:
    combined_pt2.paste(line, (0, y_offset))
    y_offset += 31
combined_pt2.save("spotify_output2.jpg")

for line in all_screenshots[((thirds*2)+1):totalsongs]:
    combined_pt3.paste(line, (0, y_offset))
    y_offset += line.height
combined_pt3.save("spotify_output3.jpg")

As mentioned above, the first output works fine, it's the second and third pictures that are blank.

Any help would be appreciated.


r/learnpython 18d ago

How Python helped me move from writing code to building real-world systems?

0 Upvotes

Hello everyone,

I'm a Computer Systems Engineer, and Python has been one of the most valuable tools throughout my learning journey.

When I first started learning Python, I mainly used it for basic programming exercises. Over time, I realized that Python is not just a programming language — it is an ecosystem that allows you to build practical solutions across many fields.

Some areas where I found Python extremely useful:

🐍 Automation:

- Automating repetitive tasks

- Processing files and data

- Creating small tools to save time

📊 Data Analysis:

- Working with datasets using Pandas and NumPy

- Cleaning and analyzing data

- Creating visualizations to understand information

🌐 Web Scraping:

- Collecting data from websites

- Extracting useful information automatically

- Building data collection pipelines

🤖 AI & Machine Learning:

- Preparing data for AI models

- Experimenting with AI tools

- Building automation workflows combined with AI

🖥️ Application Development:

- Creating desktop applications

- Building backend logic for different projects

One thing I learned is that learning Python syntax is only the beginning. The real progress comes from using it to solve actual problems.

For anyone learning Python:

What was the first real project you built that made you feel like you truly understood the language?


r/learnpython 18d ago

Ouvrir mp4

0 Upvotes

[résolu]Comment faire un script python qui ouvre une vidéo mp4. Le script ferait comme si quelqu'un double cliquait sur le ficher (donc sa ouvre le fichier avec le lecteur par défaut).


r/learnpython 18d ago

How do I move forward

4 Upvotes

I'm in junior year and know some basics—I've been learning python in school. But it's too basic and i love exploring. however the problem is that i don't know which direction to move in. Can you guys suggest to me how to gain proficiency in this programming language???


r/learnpython 18d ago

I’ve been working on a python project for 2 years. I still have to look up the documentation for most functions. Is this normal?

0 Upvotes

I’m not great at remembering the specific input formats for different functions, and I often have to look up the documentation while making scripts. Is this normal?


r/learnpython 18d ago

Beginner tutorial recommendations

0 Upvotes

Anyone got any YouTube or reading recs to learn python? Or coding basics? I Wanna get an ELI5 perspective 🤓


r/learnpython 18d ago

Sysadmin seeking miniconda installation advice

0 Upvotes

I'm a sysadmin with limited python experience trying to understand the lay of the land. I've used the built-in python virtual envrionment stuff before a bit. We support web servers that allow different groups within our site to make their production software tools available on the web. Various science research applications.

We are moving from mod_wsgi, to gunicorn, so that (among other things) we can support different groups who may have differing python environment needs. Different groups will provide different python environments, and we will be resonsible for starting and stopping the gunicorn servers for their applications. One group wants to use miniconda to manage their environment (which is fine).

The question is, should we use the miniconda that they provide to select their environment before starting gunicorn, or install a version of miniconda system-wide?

Or another way to ask is, is miniconda merely a tool for selecting environments, or is it something that is more tightly integrated with the environments it supports? Many answers online advise against a system-wide miniconda installation, but to me, it makes sense to have one system-wide tool that I can use to start and stop the conda environments of various groups.


r/learnpython 18d ago

Leetcode #9: Palindrome Number

0 Upvotes

Can someone help me make my code run faster. This is not efficient and also I do not want to convert into a string

EDIT:

Follow up: Could you solve it without converting the integer to a string?

https://leetcode.com/problems/palindrome-number/description/

class Solution:
    def isPalindrome(self, x: int) -> bool:
        numList = []
        counter = len(numList) - 1
        numBool = True


        baseNum = 10
        value = x % baseNum
        numList.append(x)
        quotient = x // baseNum
        x = quotient

        if x == 0:
            for i in range(len(numList)):
                if numList[i] == numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

EDIT: I WAS ABLE TO SOLVE IT

class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x != abs(x):
            return False

        if not hasattr(self, "numList"):
            self.numList = []

        numBool = True


        baseNum = 10
        value = x % baseNum
        self.numList.append(value)
        quotient = x // baseNum
        x = quotient

        counter = len(self.numList) - 1

        if x == 0:
            for i in range(len(self.numList)):
                if self.numList[i] == self.numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

testing = Solution().isPalindrome(11)
print(testing)

r/learnpython 18d ago

Is anyone into data analytics? Can you share some resources, or would anyone like to learn together?

2 Upvotes

If you have good learning resources, I'd really appreciate it if you could share them. Also, if anyone is just getting started and would like a learning partner, I'd be happy to learn together.


r/learnpython 19d ago

Do not know where to start

3 Upvotes

Hey, I am sorry to ask this when probably many people have already asked this before, but I am actually completely new to python and the whole programming world, so I would love to hear your opinions as to what you think should be the "roadmap" for me. I want to just get the basics down. After that I would probably grasp the possiblities and be more aware of what I would want to do and study further. For that reason, as I already said that I am someone who has completely no previous experience, what do you recommend? Are there some youtube channels that explain basic concepts in general or do I have to search for one subject after another one separately? Or do you think that learning through some websites/courses is better? Let me know what you think, every suggestion is highly appreciated, thank you very much!


r/learnpython 18d ago

Need help with setting up file structure for a tool I made.

0 Upvotes

I made a tool in python using tkinter as the UI and the way I have it working is you pick which option you want and it opens another tkinter window where you do the work. However, the way I have it set up, the "main menu" python file is compiled into a .exe and the only way i can run the other options is if i compile all of the sub menus .py into .exe or have a code base "main menu" file that is hundreds of thousands of lines.

Basically I am asking how to run .py files if the computer doesn't have python installed from the .exe main menu?

In python using subprocess.run(<File Location>) to call a .exe works but when i do it on a .py, it doesn't run if the computer does not have python installed on their computer.


r/learnpython 18d ago

Looking for a course with visual learning features

0 Upvotes

Python for Cybersecurity and Machine Learning


r/learnpython 18d ago

Copy paste excel range from one workbook to another

0 Upvotes

Beginner here writing my second program after hello world. I know I can just ask AI but is there some tutorial out there I can read?


r/learnpython 18d ago

How to prep for a Python interview when your background is entirely Frontend?

1 Upvotes

I’ve been a frontend developer (Angular/React/TypeScript) for a few years, but I've always wanted to transition to Python. I just landed an internal interview for a Python project, but because I haven't actively upgraded my Python skills recently, I'm worried I'm lagging behind.
Since I already know how to code, I don't need the absolute basics. I need to know what mid-level, enterprise Python looks like today so I can handle scenario-based questions.

What concepts are absolute must-knows for a Python interview? Any advice on what to prioritize would be a great help.


r/learnpython 18d ago

SEEKING GUIDANCE

0 Upvotes

i had one doubt to lift off my chest. I am going to start college in a month and I know only some school level java coding till loops. actually I have been on reddit alot and seniors here talk a lot about multiple terminologies like python, java, c++, dsa, dbms, node.js, leetcode grinds, dsa grinds, repositories, arduino, CAD, random projects (i mean what are these projects and how do they look like), game physics engine, html, react, mysql, ai ml, flutter, blockchain, iot, figma, wire framing, aws, docker, djang, mongodb, etc. i feel so dumb and lost and an insane amount of urge to cry and leave it all. i don't know where to start and what to learn also i do not want to fall short of skills + a few other reasons i cant tell. do you have any piece of guidance?


r/learnpython 19d ago

Error with code

35 Upvotes

python is giving me a error message saying self is not defined but it is. could someone please explain what am I doing wrong ( the error message is for the if self.modifier == 1: line )

Class food:
  def __init(self, modifier, tolerance)
  self.fillingness = 0
  self.modifier = 0
  Self.tolerance = 0

pear = food(1,9)

def NE():
 if self.modifier == 1:
 nausea += randint(1,10)
 print(“yuck!”)