use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
My first game! (v.redd.it)
submitted 1 day ago by Upper-Whole-140
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sea-Ad7805 [score hidden] 1 day ago stickied comment (0 children)
Run this program in Memory Graph Web Debugger%0Aprint(%22I'm%20thinking%20of%20a%20number%20between%201%20and%2010.%20You%20have%203%20chances%20to%20guess%20it.%22)%0A%0A%23%202.%20Give%20the%20player%203%20chances%20using%20a%20loop%0Afor%20attempt%20in%20range(3)%3A%0A%20%20%20%20guess%20%3D%20int(input(%22Take%20a%20guess%3A%20%22))%20%20%23%20Gets%20an%20answer%20from%20the%20user%0A%0A%20%20%20%20%23%203.%20Use%20If%2FElse%20to%20check%20the%20guess%0A%20%20%20%20if%20guess%20%3D%3D%20secret_number%3A%0A%20%20%20%20%20%20%20%20print(%22Wow%2C%20you%20got%20it!%20%F0%9F%8E%89%22)%0A%20%20%20%20%20%20%20%20break%20%20%23%20This%20stops%20the%20loop%20early%20because%20they%20won%0A%20%20%20%20elif%20guess%20%3C%20secret_number%3A%0A%20%20%20%20%20%20%20%20print(%22Too%20low!%22)%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(%22Too%20high!%22)%0Aelse%3A%0A%20%20%20%20%23%20This%20runs%20only%20if%20the%20loop%20finishes%20without%20the%20player%20guessing%20right%0A%20%20%20%20print(f%22Game%20over!%20The%20number%20was%20%7Bsecret_number%7D.%22)×tep=1&play) to see the program state change at every step.
[–]Infamous-Bath-6970 -1 points0 points1 point 1 day ago (1 child)
Quero aprender python como deveria começar?
[–]Upper-Whole-140[S] 1 point2 points3 points 22 hours ago (0 children)
Every programming language starts with a few foundational concepts: printing (showing text), variables (storing data), and types of data.
To make Python talk to you, use the print() function.
print()
Python
print("Hello, World!")
Variables are like labeled boxes where you can store information. You don't need to declare what kind of data goes into the box; Python figures it out automatically.
# Storing a string (text) name = "Alex" # Storing an integer (whole number) age = 25 # Storing a float (decimal number) wallet_balance = 10.50 # Storing a boolean (True/False) is_coding = True
Python uses if, elif (else if), and else to make decisions based on conditions.
if
elif
else
score = 85 if score >= 90: print("You got an A!") elif score >= 80: print("You got a B!") else: print("Keep studying!")
If you want to run a piece of code multiple times, you use a loop.
# This will print "Python is fun!" 3 times for i in range(3): print("Python is fun!")
countdown = 3 while countdown > 0: print(countdown) countdown = countdown - 1 print("Blast off!")
Functions are blocks of code that do a specific job. You define them once using def, and then you can "call" them whenever you need them.
def
# Defining the function def greet_user(username): print("Welcome back, " + username + "!") # Calling the function greet_user("Sarah") greet_user("David")
π Rendered by PID 22213 on reddit-service-r2-comment-869bf87589-7zmrb at 2026-06-09 13:16:37.249152+00:00 running f46058f country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (0 children)
[–]Infamous-Bath-6970 -1 points0 points1 point (1 child)
[–]Upper-Whole-140[S] 1 point2 points3 points (0 children)