r/learnpython • u/AutoModerator • Oct 12 '26
Ask Anything Monday - Weekly Thread
Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread
Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.
* It's primarily intended for simple questions but as long as it's about python it's allowed.
If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.
Rules:
Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
Don't post stuff that doesn't have absolutely anything to do with python.
Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.
That's it.
1
u/Remote-Dimension3884 Oct 16 '26
Waar kan ik deze code runnen, zonder programma en zonder dat ik ergens in moet loggen, dus eigenlijk online.
#Stap 1 import
import turtle
import math
import random
#Stap 2 scherm instellen
win = turtle.Screen()
win.title("RUIMTE AVONTUUR(zonder Pygame)")
win.bgcolor("black")
win.setup(width=900, height=800)
win.tracer(0)
# Stap 2.1 variabele
score = 0
lives = 5
level = 1
enemy_speed = 0.05
game_started = False
game_over = False
#2.2 define
def draw_score():
pen.clear()
pen.goto(0, 340)
pen.write(f"Score:{score} Levens: {lives} Level {level}", align="center",font=("verdana",20, "bold"))
def start_game():
global game_started
if not game_started:
game_started = True
draw_score()
def reset_game():
global score, lives, level, enemy_speed, bullet_state, game_over, game_started
score = 0
lives = 5
level = 1
enemy_speed = 0.05
bullet_state = "ready"
game_over = False
game_started = True
player.goto(0, -300)
bullet.goto(0, -600)
for enemy in enemies:
x = random.randint(-350, 350)
y = random.randint(200, 380)
enemy.goto(x, y)
pen.clear()
draw_score()
#Stap 3 Speler/Ruimteschip
player = turtle.Turtle()
player.color("cyan")
player.shape("triangle")
player.shapesize(stretch_wid=2, stretch_len=2.5,)
player.penup()
player.goto(0, -300)
player.setheading(90)
player.speed = 30
#Stap 4 Vijand
enemies = []
number_of_enemies = 3
for i in range(number_of_enemies):
enemy = turtle.Turtle()
enemy.color("red")
enemy.shape("square")
enemy.shapesize(stretch_wid=2.5, stretch_len=2.5)
enemy.penup()
enemy.speed(0)
x = random.randint(-350, 300)
y = random.randint(200, 380)
enemy.goto(x, y)
enemies.append(enemy)
enemy_speed = 0.05
#Stap 5 laser/kogel
bullet = turtle.Turtle()
bullet.color("pink")
bullet.shape("triangle")
bullet.penup()
bullet.speed(0)
bullet.setheading(90)
bullet.shapesize(stretch_wid=0.5, stretch_len=1)
bullet.goto(0, -600)
bullet_state = "ready"
bullet_speed = 2
#Stap 6 scorebord
pen = turtle.Turtle()
pen.speed(0)
pen.color("white")
pen.penup()
pen.hideturtle()
#Stap 7 Besturingfuncties
def move_left():
if game_started and not game_over:
x = player.xcor()
x -= player.speed
if x< -380:
x = -380
player.setx(x)
def move_right():
if game_started and not game_over:
x = player.xcor()
x += player.speed
if x> 380:
x = 380
player.setx(x)
def fire_bullet():
global bullet_state
if game_started and not game_over:
if bullet_state == "ready":
bullet_state = "fire"
x = player.xcor()
y = player.ycor() + 50
bullet.goto(x,y)
#Stap 8 Botsingsdetctie
def is_collision(t1,t2):
distance = math.sqrt(math.pow(t1.xcor() - t2.xcor(),2) + math.pow(t1.ycor() - t2.ycor(),2))
return distance < 40
#Stap 9 Toetsenbord koppelen
win.listen()
win.onkeypress(move_left, "Left")
win.onkeypress(move_right, "Right")
win.onkeypress(fire_bullet, "space")
win.onkeypress(reset_game, "r")
win.onkeypress(start_game, "s")
#stap / Startscherm tonen
pen.goto(0,50)
pen.write("RUIMTE AVONTUUR", align="center", font=("verdana", 30, "bold"))
pen.goto(0,-20)
pen.write("Druk op 's' om te starten", align="center", font=("verdana", 20, "normal"))
#Stap 10 Gameloop
while True:
win.update()
if game_started and not game_over:
#Stap 10.1 Kogel bewegen
if bullet_state == "fire":
y = bullet.ycor()
y += bullet_speed
bullet.sety(y)
#Stap 10.2 Kogel verlaat het scherm
if bullet.ycor() > 400:
bullet.goto(0, -600)
bullet_state = "ready"
#Stap 10.3 Vijand bewegen
for enemy in enemies:
y = enemy.ycor()
y -= enemy_speed
enemy.sety(y)
#Stap 10.4 Vijand berijkt de onderkant (GAME OVER/RESET)
if enemy.ycor()<-380:
enemy.goto(random.randint(-350,350), random.randint(300, 380))
score -= 5
if score <0:
score = 0
draw_score()
#Stap 10.5 Botssing tussen Kogel en Vijand
if is_collision(bullet, enemy):
bullet.goto(0, -600)
bullet_state = "ready"
enemy.goto(random.randint(-350,350),random.randint(300, 380))
score +=50
if score >= 500 and level == 1:
level = 2
enemy_speed += 0.1
draw_score()
#Stap 10.6 Botsing tussen Vijand en Speler
if is_collision(player, enemy):
lives -= 1
enemy.goto(random.randint(-350,350),random.randint(300, 380))
draw_score()
if lives <= 0:
game_over = True
pen.goto(0, 0)
pen.write("GAME OVER\nDruk op 'r' om te herstarten", align="center",font=("verdana",30, "bold"))
win.mainloop()
#break
Ik kan de code nu niet runnen in een dergelijke website als online python, deze doet het niet want deze ondersteunt geen Turtle. ik heb dit juist gebruikt omdat dit standaard in Python zit en je hier dus geen pip install hoeft te gebruiken.
Als dit geen mogelijkheid is moet er een programma komen die simpel is, om de code te kunnen runnen.
1
u/lakseol Oct 17 '26 edited Oct 17 '26
I can't help much with the online environments as I've never used them. A little searching found
https://python-playground.com/online-python-ide
which does work with the
turtlemodule and there are probably others.If you can accept running python on a tablet Pydroid 3 (android) or Pythonista 3 (apple) can both run turtle code. Both of those have free versions with advertisements.
0
u/Karthick_13 Oct 13 '26
Hello All I’m a QA Engineer and want to learn Python from the basics. Can anyone recommend a free website or tool that makes learning Python easy for beginners?
1
u/Educational_Virus672 Oct 13 '26
hi, i can see that your first instinct on a sub reddit called r/learnpython would be to ask for course but generally most user here take python code help and we have a community wiki for this kind of question you asked. since for some reason ppl down vote this kinds of question
i fully understand why you ask that but still this sub reddit is filled with path/course requests you can find that suits you
1
1
u/Ornery-Preference450 Oct 14 '26
Title / Subject: Recovering original Python source from Cython-compiled Windows installer after total HDD failure
Hi everyone,
I’m looking for advice on whether it’s possible (and realistic) to recover the original Python source files from a Windows software installer I still have.
Situation
My primary HDD suffered a complete, unrecoverable failure. All of my raw project files (source code, assets, intermediate files, etc.) are gone. The only remaining artifact of the project is the Windows installer / executable that I used to distribute the software.
Technical details
The application was written in Python.
I used Cython to compile / protect the code (the .py files were turned into compiled extensions / encrypted / obfuscated form as part of the build).
The final deliverable is a Windows installer (or standalone executable package).
This represents over 15 years of work. While modern AI tools could speed up a rewrite, I would strongly prefer to recover the original source if there is any viable path.
What I still have
The complete Windows installer / executable package.
No original .py files, no intermediate Cython outputs, no project folder, and no backups of the source.
What I’m hoping for
Any realistic options, tools, or techniques that might allow me to:
Extract or reconstruct the original (or close-to-original) Python source from the Cython-compiled binaries / installer, or
At least recover meaningful portions of the logic, structure, or key modules so a full rewrite is not required from scratch.
I’m aware that Cython compilation (and any additional packing/encryption I applied) makes this non-trivial, and that perfect recovery is often impossible. I’m mainly looking for an honest assessment of what’s feasible and any recommended tools, approaches, or communities that specialize in this kind of recovery / reverse-engineering of Cythonized Python applications.
If anyone has experience recovering source from Cython extensions, PyInstaller + Cython packages, or similar compiled Python Windows builds, I’d be very grateful for any pointers, tool recommendations, or realistic expectations.
Thank you in advance for any help or direction you can offer.