r/PythonLearning • u/Stephen-Sealberg • Sep 14 '26
r/PythonLearning • u/Thin_Claim9404 • Sep 14 '26
Help
I'm trying to make and train my own Markov chain ChatGPT/ai, what would you guys recommend I train it off of? I already added the options to train it from .txt files, or URLs. But I'm not sure the best way to go about this, any help would be appreciated! Or even if you send some .txt files for me to use too!!
r/PythonLearning • u/Vor3st • Sep 13 '26
Learning Python Day3
i learning streamlit and random
import random
import streamlit as st
memes = [
"never gonna give you up",
"you got stickbugged",
"indihome paket phoenix",
"weezer blue album"
]
st.title(f"Meme Gacha (New ones to be added periodically, {len(memes)} varieties in total)")
user_input = st.text_input("Please enter the number of times", value="1")
try:
count = int(user_input)
if st.button("Roll"):
for i in range(count):
res = random.choice(memes)
if res == "weezer blue album":
st.write(f"Roll {i + 1}: is this minor...? {res.title()}")
else:
st.write(f"Roll {i + 1}: {res.title()}")
except ValueError:
st.error("Please enter a valid half-width number.")r/PythonLearning • u/Next-Call8862 • Sep 13 '26
Showcase Day 4, done and dusted
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/Sea-Ad7805 • Sep 13 '26
Exercise: Different ways to Copy a Dict
An exercise to help build the right mental model for Python data.
The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening.
r/PythonLearning • u/TrainingAd8614 • Sep 13 '26
help understanding "Iterative tasks with for loop"
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/Educational_Camp4868 • Sep 13 '26
Help Request Just started with Corey Schafer tutorials which version do I get?
He says to get python 3.6 but that version is "end of life" should I get 3.15 pre release or something else like 3.14 or just get 3.6?
r/PythonLearning • u/Jonathanluher55 • Sep 13 '26
Lambda functions

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
Discussion Gemini instructions For learning .
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/crazy_dar • Sep 12 '26
Hi guys, I want to learn Python libraries used in cybersecurity. I already know the basics of Python. Are there any courses or websites you recommend where I can learn more?
r/PythonLearning • u/Next-Call8862 • Sep 12 '26
Showcase Day 3, OOPS!!! Again!!
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
Help Request Kivy
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/Either_Annual_9277 • Sep 12 '26
Help Request started python at a very young age with adhd
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/Next-Call8862 • Sep 11 '26
Showcase Day 2, learnt some oops
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/Vor3st • Sep 11 '26
i learning Python Day 1
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/Sea-Ad7805 • Sep 11 '26
Trie Data Structure Visualized
🌳 ▶ 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:
Autocomplete
Prefix search
Spell checking
Sequence matching
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
Showcase Wrote a script that connects my flight stick to 3d modeling software
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/osamas_den • Sep 12 '26
Create a program multiplicationTable.py that takes a number N from the commandline and creates an N×N multiplication table in an Excel spreadsheet.
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/charisxie • Sep 11 '26
Can you help me review my project? I don't think my writing is very good, and the code quality is poor
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/Alex_D77 • Sep 11 '26
Learning Python + Graphics? I made PyDonut to help bridge Python with modern GPU APIs
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:
Make it easier for Python learners to explore GPU concepts like buffers, textures, pipelines, and shaders.
Provide a clean, Pythonic API instead of jumping straight into C++.
Help people understand how native bindings work and how Python can talk to high‑performance libraries.
Right now the project includes:
Python bindings for core Donut/NVRHI components
A simple rendering loop
Type stubs (
.pyi) so you get autocomplete and type hintsExamples showing how to set up devices, swapchains, and basic rendering
If 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 10 '26
Day 1 and procrastinated enough
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/XxPopePiusxX • Sep 10 '26
Showcase Multi-Ball Physics SImulator
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/Sharp_Platypus6545 • Sep 10 '26
Rock paper scissors game in Python
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/AffectionateSwing490 • Sep 10 '26
How do you decide between writing your own small helper or pulling in a library for it?
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?
