A
Aura DevPython Cheatsheet
Python syntax and standard library.
Variables & Types
Basic Types
x = 10 # int y = 3.14 # float name = "Alice" # str is_active = True # bool
Type Conversion
str(10) # "10"
int("10") # 10
float(10) # 10.0Data Structures
Lists
nums = [1, 2, 3] nums.append(4) nums[0] # 1 nums[-1] # 4
Dictionaries
user = {"name": "Alice", "age": 25}
user["name"] # "Alice"
user.get("id") # NoneSets & Tuples
coords = (10, 20) # Tuple (immutable)
unique = {1, 2, 2, 3} # Set: {1, 2, 3}Control Flow
If / Else
if x > 0:
print("Positive")
elif x == 0:
print("Zero")
else:
print("Negative")Loops
for i in range(5):
print(i)
while x > 0:
x -= 1Functions & Classes
Functions
def greet(name="World"):
return f"Hello, {name}!"
add = lambda x, y: x + yClasses
class Person:
def __init__(self, name):
self.name = name
def say_hi(self):
print(f"Hi, I'm {self.name}")What is Python?
Python is a high-level, versatile programming language known for its readability and extensive standard library.
This cheatsheet covers essential Python syntax, data structures, loops, and functions for quick reference during development.
Sponsored LinkAdvertisement Space (728x90)