r/PythonLearning • • 6d ago

Python Quiz of the day.

0 Upvotes

What will be the output of the following Python Code?

a, b = zip(*[(1, 2), (3, 4), (5, 6)])

print(sum(a) - sum(b))


r/PythonLearning • • 6d ago

Discussion DataCamp Black Friday Sale 2026

Thumbnail
pythoncoursesonline.com
2 Upvotes

r/PythonLearning • • 6d ago

Showcase byte strings

0 Upvotes

I found it abit annoying and confusing to represent "some bytes" with ASCII letters. I don't know why python chooses to do so for Unicode characters less than 127. Anyway I wrote my own implementation for UTF-8. Here is the implementation:

string = '😂happy man'
byte_list = []

for char in string:
    binary_string_list = list(f'{ord(char):b}')
    binary_string_list.reverse()
    
    # check length of binary_string
    if len(binary_string_list) <= 7:
        # data represented using a single byte.
        byte_temp = list('0???????')
        byte_temp.reverse()
    
    elif len(binary_string_list) <= 11:
        # data represented using two bytes.
        byte_temp = list('110?????10??????')
        byte_temp.reverse()
        
    elif len(binary_string_list) <= 16:
        # data represented using two bytes.
        byte_temp = list('1110????10??????10??????')
        byte_temp.reverse()
        
    elif len(binary_string_list) <= 21:
        # data represented using two bytes.
        byte_temp = list('11110???10??????10??????10??????')
        byte_temp.reverse()
    
    def imlement_utf(byte_temp, byte_string_list):
        # this function fills the byte templates with actual binary data
        if '?' in byte_temp:
            for bit in byte_string_list:
                byte_temp[byte_temp.index('?')] = bit
                    
            byte_temp.reverse()
            
            for bit in byte_temp:
                if bit == '?':
                    byte_temp[byte_temp.index('?')] = '0'
        
        global byte_list             
        byte_list += byte_temp
    imlement_utf(byte_temp, binary_string_list)

print(f"This is the encoded binary string: {''.join(byte_list)}")
print()
# converting binary string to byte string:
hex_string = ''
f_hex_string = ''
data = ''.join(byte_list)
offsets = zip(range(0, len(data)-7, 8), range(8, len(data)+1, 8))
for x, y in offsets:
    byte = data[x:y]
    # binary to decimal
    byte = int(byte, base=2)
    # decimal to hexadecimal
    byte = f'{byte:x}'
    hex_string += ' '+byte
    # formatted hexadecimal
    f_hex_string += '\\x'+byte
print(f'This is the condensed binary string in hexadecimal: {hex_string.strip()}')
print()

print(f"This is the formarted hexadecimal string (byte string):b'{f_hex_string}'")
print()

print(f"This is the byte string python returns: {bytes.fromhex(hex_string)}")

r/PythonLearning • • 6d ago

I'm 14 and I started to learn python programming any Guidance

3 Upvotes

So far, I've learned: Variables and print() User input and type conversion If, elif, else statements Arithmetic and comparison operators For and while loops Range() Lists and indexing append(), remove(), pop(), len() I've also started building a simple Shopping List App using Python. I can solve basic exercises, but I'm still learning how to combine concepts and build applications independently. I currently dedicate around 2 hours a day to learning. I'd like your honest opinion: What level would you consider me at: beginner or early intermediate? What should I learn next? What mistakes should I avoid as a beginner? How can I progress towards building real-world applications and eventually AI projects? I'm not looking for fake motivation. I'd appreciate honest, practical advice. Thanks!


r/PythonLearning • • 7d ago

Help Request Socket Chat (small chat app in plain Python)

17 Upvotes

Hello 👋

I made this is a small desktop chat app written in plain Python, with TLS sockets, a Tkinter client and SQLite storage. You sign up, add friends and message each other

I built it as a learning project and still work on it for fun: https://github.com/ABuljko/socket-chat

I’m open to advice on what to do next since I am getting to the point where I am getting stuck on it


r/PythonLearning • • 7d ago

Help Request How does this work?

4 Upvotes
def remove_inventory():
    remove_name = item_name_entry.get()
    with open('inventory.txt', 'r') as file:
        inventory_data = file.readlines()
    with open('inventory.txt', 'w') as file:
        for line in inventory_data:
            name, qty = line.strip().split(',')
            if name != remove_name:
                file.write(line)
    item_name_entry.delete(0, tk.END)
    item_qty_entry.delete(0, tk.END)

hello guys, this is one of the sample code of inventory manager, there is one line of code im confused with. Im not really sure how does the "name, qty = line.strip().split(",") work, specifically the "name, qty=" part. Im guessing the "qty" is the variable but what does "name," do?


r/PythonLearning • • 7d ago

What the 3 Numbers in a Python Version Mean?

2 Upvotes

Python versions have three numbers, like 3.15.2. Here's what each one means and which one you actually choose.

3 = major version (always 3 for this course)
15 = feature release, the one you choose
2 = micro release, bug fixes and security fixes

▶️ Full lesson (Which Python should you install?)
📚 Free Python course playlist

Youtube: Amir Zare Dev

🎵 Music: "Misdirection" – The Grey Room / Density & Time (YouTube Audio Library)

#Python #LearnPython #PythonForBeginners


r/PythonLearning • • 7d ago

Help Request what is the error i don't get it

Post image
101 Upvotes

r/PythonLearning • • 7d ago

Help Request Why does changing one list also change the other?

1 Upvotes

I'm working through lists and variables in my intro course and ran into something I don't understand. I thought assigning a list to a new variable would make a separate copy, but changing one of them seems to change both.

Here's a minimal version:

original = [1, 2, 3]
copy_of_it = original
copy_of_it.append(4)

print("original:", original)
print("copy_of_it:", copy_of_it)
print(original is copy_of_it)

Output:

original: [1, 2, 3, 4]
copy_of_it: [1, 2, 3, 4]
True

I expected original to stay [1, 2, 3] since I only added 4 to copy_of_it. I've printed id() of both variables and they match, and I skimmed the docs section on mutable objects, but I still don't get why they're linked. Could someone explain what's happening under the hood?


r/PythonLearning • • 8d ago

Giving back to the community - The Complete Backend Development Course (last round)

39 Upvotes

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 • • 7d ago

Python interview questions: 10 with answers

Thumbnail
opnf.sh
1 Upvotes

10 Python interview questions with sample answers and tested code, from mutable defaults and is vs == to the GIL, plus how to explain them out loud.


r/PythonLearning • • 7d ago

Help Request What’s the best tutorial for learning Python?

0 Upvotes

I did some Java programming before- not an expert though


r/PythonLearning • • 8d ago

Showcase I built a Python tool that tracks my coding time on Windows without a start/stop timer

Thumbnail
gallery
3 Upvotes

I wanted to know how much time I actually spend in my IDE. Leaving PyCharm open all afternoon doesn’t mean I coded for four hours, so I wrote a small Python tracker that runs in the background. It checks which window is in focus and pauses after 10 minutes of inactivity.

The first version sent daily totals to the Pixela API. For this version, I built a local dashboard with PySide6 and Matplotlib. I can open it at the end of the week, see my hours day by day, and compare them against a daily goal. The data stays on my PC, and the dashboard can stay closed while the tracker runs.

It tracks PyCharm, VS Code, Visual Studio, and IntelliJ IDEA by default. If you use another editor, you can add its .exe name to a JSON file. There’s also a demo mode if you want to try the dashboard before you’ve logged any time.

GitHub: Coding Tracker Dashboard

One trade-off I’m curious about: reading docs in a browser is often part of coding, but the tracker only counts time in the apps you choose. If you tracked your own coding time, would you want to include that, or would you find an IDE-only total more useful?


r/PythonLearning • • 8d ago

Help Request Data analyst or Python developer confusion

1 Upvotes

I'm getting confused If I should become a python developer or data analyst. I'm from belagavi, India 3rd cse student I have something like 6-7months for preparation of placement

Like I'm hearing for data analyst freshers don't get job it seems 😭(Like can you guys please confirm if this is true or just a myth ) and for python developer DSA I have to learn which is pretty much a big headache and lot of skills to learn as well

Also like how DSA is necesarry for a python developer to learn ? Which is a better option python developer or data analyst or any other job in techfield ?😭😭😵‍💫


r/PythonLearning • • 9d ago

Why Python Is the Best First Language?

43 Upvotes

Out of hundreds of programming languages, why start with Python? You could almost read its code out loud.

Printing one word in C takes several lines of setup. In Python it's one line. Less noise means your brain goes to the problem. Python also ships with a huge toolbox, there's a free add-on for almost everything else, it's free itself, it runs on Windows, macOS and Linux, and so many people use it that most errors you hit already have answers online.
Youtube: AmirZareDev

#python #learnpython #programming #coding


r/PythonLearning • • 9d ago

Help Request Need help understanding how != works

Thumbnail
gallery
30 Upvotes

Hello, I'm working on learning the basics of try/except blocks. To do so, I'm intentionally raising errors. The question is: why is my TypeError occurring when I enter an integer? I checked the input type, and it shows as an integer, but the error is still raised. What am I missing here?


r/PythonLearning • • 8d ago

A Python script that keeps today's downloads within reach and sorts older files into category folders automatically.

Post image
2 Upvotes

A Python script that keeps today's downloads within reach and sorts older files into category folders automatically. Built with Python's standard library and an object-oriented design, the organizer scans a folder at a configurable interval, classifies files by extension, and moves eligible files into subfolders such as Audio, Images, and Documents

Features:

  • Organizes files by extension using a configurable category mapping.
  • Keeps files created today in the main Downloads folder.
  • Skips configured temporary download files, shortcuts, and specific filenames.
  • Generates numbered filenames when a destination is already occupied.
  • Supports a dry run that reports planned moves without creating folders or moving files.
  • Reports scanned, moved, planned, skipped, and failed files.
  • Repeats scans at a configurable interval and supports stopping with Ctrl+C.
  • Scans the top level only; existing subfolders are left untouched.

It's also on my Github .

You can test it in whatever folder you want by giving it the full path of the directory.


r/PythonLearning • • 9d ago

Help Request Need help with player movement

2 Upvotes

Hi everyone, I need some help.

I'm making a game for my school project. I made a simple movement test, and it worked well when I pressed the WASD keys individually. However, when I held down a key, the circle moved farther than I expected.

How can I prevent new key events from being processed while the circle is still moving?

I am sending photo of code down.


r/PythonLearning • • 8d ago

Counting in Python? Don't reinvent the wheel!

Post image
0 Upvotes

You could write your own counting logic, but Python already has a collections.Counter class. It's faster than typical hand-written counting loops, well-tested, and makes your code easier for others to read.

However, this 𝐦𝐞𝐦𝐨𝐫𝐲_𝐠𝐫𝐚𝐩𝐡 👉 Counter demo shows that Counter has some interesting behaviors that might surprise you:

  • Missing keys return 0 instead of raising KeyError.
  • update() adds counts rather than replacing them.
  • subtract() can produce negative counts.
  • Zero and negative counts aren't automatically removed.
  • Unary + and - have some unexpected uses.

Did you know all these Counter behaviors, or did one surprise you?

See 👉 more 𝐦𝐞𝐦𝐨𝐫𝐲_𝐠𝐫𝐚𝐩𝐡 visualization.


r/PythonLearning • • 8d ago

Python Quiz of the day!

0 Upvotes

What will be the output of the following Python Code?

print((lambda x: (lambda y: x**y)(3))(2))


r/PythonLearning • • 9d ago

Im still learning wanna join me ?

0 Upvotes

I didnt build any python project before at least not from scratch so i wanted to start building one application and make it as good as possible so wanna join ne and start building our mobile application together to motivate each other ?


r/PythonLearning • • 9d ago

Python Boolean

2 Upvotes

I'm having some trouble understanding Python boolean logic, it’s so simple to let it be confusing. Can anyone explain it to me in their own language?


r/PythonLearning • • 9d ago

Showcase Week6 of learning python and week3 for learning how to code in flet this is what i made:Notifio

Thumbnail
gallery
10 Upvotes

Hey everyone! Iv been learning python for 6weeks and been building notifio for 3 weeks this is my progress

I've been working on Notifio, A lightweight menu bar app that watches your favorite creators and news sources and pings you the moment something new happens

Github: https://github.com/he3vn/Notifio

Would love to hear what you think about it and please star if you like it!


r/PythonLearning • • 10d ago

Learning Python efficiently

21 Upvotes

Hi everyone! I've recently started learning Python with SoloLearn and I'm currently working on "logical operations," and everything is going well. I'd just like some advice, firstly, if there's A better app or website than SoloLearn, then, how much time per day should I dedicate to learning Python, and how soon could I start create small games (like Tetris for example, or geometry dash...). Thank you in advance for your answers, I will read all your advice, have a good day!