Program Editor (INPUT)

Ctrl + Enter to run

Console (Output)

Ready

📖 Python Quick Reference

Output & Input

print("Hello!")              # Display output
print("x =", x)             # Multiple values
print(f"Hi {name}!")         # f-string (easiest!)
name = input("Name: ")       # Returns a STRING
age  = int(input("Age: "))   # Convert to integer

Variables & Math

x = 10       # Integer
y = 3.14     # Float
s = "Alice"  # String
b = True     # Boolean

x + y    x - y    x * y
x / y    # Float division  (10/3 = 3.333)
x // y   # Integer division (10//3 = 3)
x % y    # Modulus/remainder (10%3 = 1)
x ** y   # Exponent          (2**8 = 256)

Conditionals

if x > 10:
    print("greater")
elif x == 10:
    print("equal")
else:
    print("less")

# Boolean operators (lowercase!)
if x > 0 and x < 100:
if x < 0 or x > 100:
if not flag:

Loops

for i in range(5):        # 0 to 4
    print(i)

for i in range(1, 11):    # 1 to 10
    print(i)

for item in myList:        # each element
    print(item)

while count < 10:
    count += 1

Lists (0-indexed!)

nums = [10, 20, 30, 40]
nums[0]              # First element
nums[-1]             # Last element
len(nums)            # Number of elements
nums.append(50)      # Add to end
nums.insert(1, 15)   # Insert at index
nums.remove(20)      # Remove first match
nums.pop()           # Remove & return last

Functions

def greet(name):
    return "Hello, " + name + "!"

result = greet("Alice")
print(result)

Strings

text = "Hello World"
text.upper()        # "HELLO WORLD"
text.lower()        # "hello world"
text[0]             # "H"  (0-indexed)
text[1:5]           # "ello" (slice)
len(text)           # 11
text.split(" ")     # ["Hello", "World"]
" ".join(myList)    # list → string

Modules

import math
math.sqrt(16)   math.pi   math.pow(2, 8)
math.floor(3.7) math.ceil(3.2)

import random
random.randint(1, 6)      # Inclusive
random.choice(myList)     # Random element
random.random()           # Float 0.0–1.0
ARIA
ARIA
Python Helper