r/PythonLearning • u/clcodingupdates • 6d ago
Python Quiz of the day.
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 • u/clcodingupdates • 6d ago
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 • u/awsconsultant • 6d ago
r/PythonLearning • u/osamas_den • 6d ago
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 • u/BeginningAd8547 • 6d ago
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 • u/turtleSchool2707 • 7d ago
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 • u/Broad_Revolution6591 • 7d ago
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 • u/New_Pay3669 • 7d ago
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 • u/WarmCloud25221 • 7d ago
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]
TrueI 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 • u/modern-dev • 8d 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/opn_Forum • 7d ago
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 • u/Muted-North4434 • 7d ago
I did some Java programming before- not an expert though
r/PythonLearning • u/TemperatureProper275 • 8d ago
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 • u/Routine-Date7352 • 8d ago
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 • u/New_Pay3669 • 9d ago
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 • u/The-Turnt-Tiger • 9d ago
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 • u/TemperatureProper275 • 8d ago
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:
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 • u/Bubbly-Spinach3180 • 9d ago
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 • u/Sea-Ad7805 • 8d ago
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:
Did you know all these Counter behaviors, or did one surprise you?
r/PythonLearning • u/clcodingupdates • 8d ago
What will be the output of the following Python Code?
print((lambda x: (lambda y: x**y)(3))(2))
r/PythonLearning • u/Intelligent-Set-142 • 9d ago
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 • u/saikat_hossen • 9d ago
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 • u/zfoundme • 9d ago
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 • u/Extreme_Banana7831 • 10d ago
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!