r/PythonLearning • u/ApprehensiveText9058 • Sep 13 '26
Help Request What wrong with my code
Need help
r/PythonLearning • u/ApprehensiveText9058 • Sep 13 '26
Need help
r/PythonLearning • u/Next-Call8862 • Sep 13 '26
I won't exactly say done and dusted but I think I did what I can. This is my first complex problem that I had done myself and after solving it I left thinking, "I could do this in three days and I could have done much more in 1.5 years that I had wasted" but I think it's alright and I should look ahead with no regret. Will appreciate some tips from pros regarding the code.
Edit: I did a mistake and there are some bugs in programm, I fixed them
The updated code:
'''
class Library:
Books ={
1 : "Ramayan" ,
2 : "Mahabharath",
3 : "Gita"
}
members = ["naveen","sita","mani","chintu"]
Allowence = {
"naveen" : 0,
"sita" : 0,
"mani" : 0,
"chintu" : 0
}
Booked = {}
def __init__(self,member):
self.member = member
def get(self,book):
self.book = book
if self.member not in Library.members:
return "Not a member"
elif self.book not in Library.Books and self.book in Library.Booked:
return "Not available"
elif self.book not in Library.Books:
return "No book found"
elif self.member in Library.members and Library.Allowence[self.member] < 3:
a = Library.Books.pop(self.book)
Library.Booked[self.book] = a,self.member
Library.Allowence[self.member] +=1
return f"Your book :{a}"
else:
return "limit exceeded"
def about_cus(self):
return Library.Allowence[self.member]
def tst(self):
return Library.Booked
Nam = input("Your name:")
Req = int(input("Select the book num"))
customer1 = Library(Nam)
print(customer1.get(Req))
Nam2 = input("Your name:")
customer2 = Library(Nam2)
print(customer2.get(Req))
print(customer2.tst())
# print(customer2.available())
print(customer1.about_cus())
#NOTHING HERE!!r/PythonLearning • u/TrainingAd8614 • Sep 13 '26
Hello all,
I sort of understand the utility of "for", however I really cannot understand how this:
protocol = "HTTPS"for char in protocol:
print(f"Segment: {char}")
Outputs this ;
Segment: H
Segment: T
Segment: T
Segment: P
Segment: S
How can it break up the string "HTTPS" into four separate outputs?
Thank you
r/PythonLearning
•
u/shubham_555
•
Sep 13 '26
Last Post - https://www.reddit.com/r/PythonLearning/s/kGqwMS9HUH
Github Repo - https://github.com/Dev-4-All/bank.git
r/PythonLearning • u/Jonathanluher55 • Sep 13 '26

Hello guys, recently I have been practicing more my python skills. I know how to def functions and use it, but now I am trying to study lambda functions, but is not clear for me. In this example I am simulating requests from a API as a List (Also it could be used directly a imported file like a JSON). Can someone explain me how works or what kind of exercises are good to understand it?
r/PythonLearning • u/Previous-Jury-4415 • Sep 12 '26
These are instructions for Gemini, specifically for its Gems feature. These instructions are designed to make the AI act as a good teacher, mainly for programming.
I’d like to hear your opinions after trying them. Do you think they’re actually useful for learning programming, or do they need some additions or specific modifications?
Thanks!
Topic learning = Teach the concept. If the learner says they do not understand, deepen the explanation progressively until the concept is clear.
Exercise explanation = Explain the task, not the implementation.
Hint requested = Gradually reveal reasoning, never the final implementation.r/PythonLearning • u/Next-Call8862 • Sep 12 '26
I think it's alright to revolve around for better understanding. I tried w3 schools and it seems better with some tiny quiz and all. I think I will solve some problems from each tier so I could get better in using OOPS
r/PythonLearning • u/Kazuya746 • Sep 12 '26
I have been learning python for a while and made some projects, my exams are currently going on so I can't start web dev, but I thought I could learn kivy in the meanwhile to make an app for my studying bcz there isn't an app that fits my requirement. So needed some resources and advice for kivy module.
I tried kivy documentation but it's like they don't have each topics lined up, so I have to search each topics, but I don't even know the existence of specific topics, so yeah.
Thanks for the help in advance!!
r/PythonLearning • u/crazy_dar • Sep 12 '26
r/PythonLearning • u/Either_Annual_9277 • Sep 12 '26
i started python at a young age with adhd, the math in python is too hard to learn i cant focus on learning, i need a way to learn python easily, i watch youtube totorial to learn btw
r/PythonLearning • u/osamas_den • Sep 12 '26
import sys, openpyxl
from openpyxl.styles import Font
x = int(sys.argv[1])
list = []
wb = openpyxl.Workbook()
font_style = Font(bold=True)
for i in range(1, x+1):
list.append(i)
for number in list:
sheet = wb['Sheet']
# write header columns and rows in bold numbers
sheet.cell(column=1, row=number+1).value = number
sheet.cell(column=1, row=number+1).font = font_style
sheet.cell(row=1, column=number+1).value = number
sheet.cell(row=1, column=number+1).font = font_style
# create two for loops that will multiply
for i in range(len(list)):
for number in list:
mult = list[i] * number
sheet.cell(row=number+1, column=i+2).value = mult
wb.save('multiplication_table.xlsx')r/PythonLearning • u/Vor3st • Sep 11 '26
lyrics = ["Give You Up","Let You Down","Run Around And Desert You"]
for i in range(3):
print("Never Gonna " + lyrics[i])
r/PythonLearning • u/Alex_D77 • Sep 11 '26
I’ve been learning more about graphics programming lately, and I wanted a way to experiment with real GPU rendering concepts without switching away from Python. So I started building a project called PyDonut — a Python wrapper around the Donut rendering framework (which itself uses NVRHI).
👉 Repo: https://github.com/ASDAlexander77/PyDonut
My goals with PyDonut are:
Right now the project includes:
.pyi) so you get autocomplete and type hintsIf you’re learning Python and want to explore graphics, native extensions, or how Python interacts with C++ libraries, feel free to check it out. Feedback is welcome — especially from beginners who can tell me what feels confusing or what would help them learn better.
Happy coding!
PS. I’m still learning Python myself — PyDonut is actually my first real Python project.
r/PythonLearning • u/Next-Call8862 • Sep 11 '26
Learnt super( ), inheritance, polymorphism, class method and static method and don't mind the messy code that's me trying to figure out things
r/PythonLearning • u/charisxie • Sep 11 '26
This is my GitHub link: https://github.com/chaoxie2005/spider-gateway. I am a college student who has just started my internship
r/PythonLearning • u/Sea-Ad7805 • Sep 11 '26
🌳 ▶ Open the interactive trie visualization
A trie is a tree-shaped data structure that can be implemented elegantly in Python using nested dictionaries (hash tables).
Tries are often used for:
Visualizing data structures with memory_graph makes them much easier to understand and debug, especially for students learning Python.
r/PythonLearning • u/lucabuilds • Sep 11 '26
Just wanted to show how versatile python is. I made a script that reads joystick input through pygame and broadcasts telemetry through the local network. A fusion 360 (the modeling software) add-in, also written in python, reads from the local network and transforms the input into camera movement (orbiting and zoom).
What do you think?
r/PythonLearning • u/AffectionateSwing490 • Sep 10 '26
I'll need some small piece of functionality and I have to decide whether to write 20 lines myself or install a library that already does it. Both options feel wrong in different ways. If I write it myself, I might miss edge cases someone else already solved. If I pull in a library, I've now added a dependency for something I could have handled in a few lines.
An example. I once needed to flatten a nested list. I could have written a short function but I added a library instead. Later that library caused a version conflict, and I sat there wondering why I hadn't just written the five lines myself. Now I lean toward writing small stuff myself and saving libraries for the harder problems, like date parsing or anything security related where I don't trust my own version. But I still second-guess it constantly.
So how do you decide? Is there a point where you know for sure it's worth adding a dependency or do you go by feel each time?
r/PythonLearning • u/XxPopePiusxX • Sep 10 '26
This is my multi-ball physics python simulator. This was my first foray into vector physics and pygame in general. I used a Ball class to create multiple balls and then a couple nested loops to create the 2D collision physics. Also the numbers running off in the terminal is the sum of all the balls velocities to show real energy loss.
AI Disclaimer: AI did not write a line of this code, however, it was used to understand vector physics, and some light trouble shooting when I couldn't figure out why I was stuck. I understand and wrote every line. Please let me know if you think I over stept with its use.
import pygame
import random
class Ball():
def __init__(self, position=(0,0), velocity=(.5,.5), r=12):
self.position = (random.randint(220,550),random.randint(150,480))
self.velocity = random.uniform(-.5,.5),.5
self.r = r
def create_ball(self, screen):
pygame.draw.circle(screen, (0,0,255), self.position, self.r )
def change_position(self):
gravity = .5
friction = .95
x , y = self.position
vx , vy = self.velocity
x = x + vx
vy = vy + gravity
y = y + vy
if x + self.r >= 593:
vx = -vx
x = 593 - self.r
if x - self.r <= 207:
vx = -vx
x = 207 + self.r
if y + self.r >= 493:
vy = -vy
y = 493 - self.r
if y == (493- self.r):
vx = vx * friction
if y - self.r <= 107:
vy = -vy
y = 107 + self.r
self.position = (x,y)
self.velocity = (vx,vy)
pygame.init()
screen = pygame.display.set_mode((800, 600))
square = pygame.Rect(0,0,400,400)
square.center = (400,300)
clock = pygame.time.Clock()
total_balls = [Ball() for i in range(5)]
run = True
while run:
clock.tick(30)
screen.fill((0,0,0))
pygame.draw.rect(screen, (255, 255, 255),square, width=7)
for ball in total_balls:
ball.create_ball(screen)
ball.change_position()
for ball1 in total_balls:
if ball is ball1:
continue
v1 = pygame.math.Vector2(ball.position)
v2 = pygame.math.Vector2(ball1.position)
v3 = pygame.math.Vector2(ball.velocity)
v4 = pygame.math.Vector2(ball1.velocity)
overlap = (ball.r + ball1.r) - v1.distance_to(v2)
if v1.distance_to(v2) < (ball.r + ball1.r):
line_vector = (v2 - v1).normalize()
push = line_vector * (overlap/2)
ball.position = (ball.position - push)
ball1.position = (ball1.position + push)
scaler1 = pygame.math.Vector2.dot(v3,line_vector)
scaler2 = pygame.math.Vector2.dot(v4,line_vector)
v_along1 = scaler1 * line_vector
v_along2 = scaler2 * line_vector
vperp_ball1 = v3 - v_along1
vperp_ball2 = v4 - v_along2
ball.velocity = v_along2 + vperp_ball1
ball1.velocity = v_along1 + vperp_ball2
print(sum([(ball.velocity[0] * ball.velocity[0]) + (ball.velocity[1] * ball.velocity[1]) for ball in total_balls]))
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.display.update()
pygame.quit()
r/PythonLearning • u/camerongreen95 • Sep 10 '26
We're running a hands-on masterclass on September 12, Live LLM Engineering Masterclass: Production Evals, RAG, Agents & LLMOps.
Fully hands-on, all in Python notebooks against real model APIs (OpenAI, Anthropic), not slides or theory. You write actual code across the full stack: versioned prompt pipelines with structured outputs and regression tests, a golden dataset and eval harness combining deterministic checks with LLM-as-judge scoring, statistically rigorous model comparisons using scipy-style bootstrap confidence intervals and paired significance tests, evaluated RAG with embedding models, vector retrieval, and reranking, tool-using agents with function calling and guardrails, and a full observability layer for tracing, cost, and latency. You also leave with a CLI regression suite you can wire directly into CI.
Led by Bruno Gonçalves, PhD, founder of Data For Science, who trains engineers at Fortune 500 companies on this exact stack.
Link if you want to check it out
Happy to answer questions on the content, especially the Python side of things.
r/PythonLearning • u/Next-Call8862 • Sep 10 '26
Wasted a year and will no more, started where I left 1.5years ago and I am picking it again and will post it every day in the sub. Did this problem and bro it was hurting my brain until I learned the basic OOP and been doing for hours and am planning to learn 4 to 6 hrs a day. Hope the mods allow everyday progress
r/PythonLearning • u/Sharp_Platypus6545 • Sep 10 '26
Hello fam, I'm learning Python. My goal is to become an AI engineer. I've a basic understanding of programming. Anyone to guide me on the right certification path... I was having a bit of fun after today's sharpenings. I created a rock paper scissors game... rate and improve
r/PythonLearning • u/Playful_Rooster_4246 • Sep 10 '26
Hey everyone! I’ve been grinding away on some coding projects recently and wanted to put them all in one place.
I built a GitHub repository featuring a mix of beginner and intermediate Python projects alongside some simple web development builds. The idea is that anyone can clone it, build them out locally, and use them to practice or experiment.
Here is the link: https://github.com/zensiuu/Coding-Projects-Python-JS-.git
Since I'm still working on getting better at writing clean, efficient code, I would genuinely appreciate your honest feedback. Let me know what I can improve, what’s missing, or any tips you have for a developer looking to level up.
Happy coding! 🚀
r/PythonLearning • u/Repulsive-Buyer1322 • Sep 10 '26
I have gone through python basics and some of the intermediate stuff. I don't know anything about databases or algorithms. I pretty much learned python syntax, variables, loops, conditionals, operators etc. When I think like what should I do with python moving forward, I don't know.Career wise I am a fresher who does not have a tech background. Should I have to learn databases and algorithms.
What is your opinion on leet code and kaggle.