Python Cheatsheet π
1οΈβ£ Variables & Data Types
x = 10 (Integer)
y = 3.14 (Float)
name = "Python" (String)
is_valid = True (Boolean)
items = [1, 2, 3] (List)
data = (1, 2, 3) (Tuple)
person = {"name": "Alice", "age": 25} (Dictionary)
2οΈβ£ Operators
Arithmetic: +, -, *, /, //, %, **
Comparison: ==, !=, >, <, >=, <=
Logical: and, or, not
Membership: in, not in
3οΈβ£ Control Flow
If-Else:
if age > 18:
print("Adult")
elif age == 18:
print("Just turned 18")
else:
print("Minor")
Loops:
for i in range(5):
print(i)
while x < 10:
x += 1
4οΈβ£ Functions
Defining & Calling:
def greet(name):
return f"Hello, {name}"
print(greet("Alice"))
Lambda Functions: add = lambda x, y: x + y
5οΈβ£ Lists & Dictionary Operations
Append: items.append(4)
Remove: items.remove(2)
List Comprehension: [x**2 for x in range(5)]
Dictionary Access: person["name"]
6οΈβ£ File Handling
Read File:
with open("file.txt", "r") as f:
content = f.read()
Write File:
with open("file.txt", "w") as f:
f.write("Hello, World!")
7οΈβ£ Exception Handling
try:
result = 10 / 0
except ZeroDivisionError:
print("Cannot divide by zero!")
finally:
print("Done")
8οΈβ£ Modules & Packages
Importing:
import math
print(math.sqrt(25))
Creating a Module (mymodule.py):
def add(x, y):
return x + y
Usage: from mymodule import add
9οΈβ£ Object-Oriented Programming (OOP)
Defining a Class:
class Person:
def init(self, name, age):
self.name = name
self.age = age
def greet(self):
return f"Hello, my name is {self.name}"
Creating an Object: p = Person("Alice", 25)
π Useful Libraries
NumPy: import numpy as np
Pandas: import pandas as pd
Matplotlib: import matplotlib.pyplot as plt
Requests: import requests
@CodingCoursePro
Shared with Loveβ₯οΈ
1οΈβ£ Variables & Data Types
x = 10 (Integer)
y = 3.14 (Float)
name = "Python" (String)
is_valid = True (Boolean)
items = [1, 2, 3] (List)
data = (1, 2, 3) (Tuple)
person = {"name": "Alice", "age": 25} (Dictionary)
2οΈβ£ Operators
Arithmetic: +, -, *, /, //, %, **
Comparison: ==, !=, >, <, >=, <=
Logical: and, or, not
Membership: in, not in
3οΈβ£ Control Flow
If-Else:
if age > 18:
print("Adult")
elif age == 18:
print("Just turned 18")
else:
print("Minor")
Loops:
for i in range(5):
print(i)
while x < 10:
x += 1
4οΈβ£ Functions
Defining & Calling:
def greet(name):
return f"Hello, {name}"
print(greet("Alice"))
Lambda Functions: add = lambda x, y: x + y
5οΈβ£ Lists & Dictionary Operations
Append: items.append(4)
Remove: items.remove(2)
List Comprehension: [x**2 for x in range(5)]
Dictionary Access: person["name"]
6οΈβ£ File Handling
Read File:
with open("file.txt", "r") as f:
content = f.read()
Write File:
with open("file.txt", "w") as f:
f.write("Hello, World!")
7οΈβ£ Exception Handling
try:
result = 10 / 0
except ZeroDivisionError:
print("Cannot divide by zero!")
finally:
print("Done")
8οΈβ£ Modules & Packages
Importing:
import math
print(math.sqrt(25))
Creating a Module (mymodule.py):
def add(x, y):
return x + y
Usage: from mymodule import add
9οΈβ£ Object-Oriented Programming (OOP)
Defining a Class:
class Person:
def init(self, name, age):
self.name = name
self.age = age
def greet(self):
return f"Hello, my name is {self.name}"
Creating an Object: p = Person("Alice", 25)
π Useful Libraries
NumPy: import numpy as np
Pandas: import pandas as pd
Matplotlib: import matplotlib.pyplot as plt
Requests: import requests
@CodingCoursePro
Shared with Loveβ₯οΈ
π1
Wow π±
5000+ AI Tools π
β’ All In One Place π
β’ Find Anything Here About Ai π€
Site Link π
https://www.aixploria.com
@CodingCoursePro
Shared with Loveβ₯οΈ
5000+ AI Tools π
β’ All In One Place π
β’ Find Anything Here About Ai π€
Site Link π
https://www.aixploria.com
@CodingCoursePro
Shared with Loveβ₯οΈ
βοΈ Thoughts in the head
Prompt template:
@CodingCoursePro
Shared with Loveβ₯οΈ
Prompt template:
A surreal photograph of a large, brightly colored human head with a cut-out at the top, revealing a flat surface inside the skull. On this inner surface stands a small, [SCENE]. The top of the head, including the hair, hovers above the bottom, as if it had been carefully cut away and levitated. The style is glossy and hyperrealistic, with textures. The scene is abstract and symbolic, perhaps representing introspection, consciousness, or the inner world of the mind. The scene inside the head reinforces the surreal and philosophical tone of the artwork.@CodingCoursePro
Shared with Loveβ₯οΈ
π° ππ¨π° ππ¨ ππ’π¬π ππ¨ππ’ππ’ππ π
π’π₯ππ¬ ππππ°πππ§ ππ©πππ’ππ’π πππ§π π ππ πππ²π¬ ππ² πππ¬π‘ ππ§π ππ²ππ‘π¨π§
@CodingCoursePro
Shared with Loveβ₯οΈ
@CodingCoursePro
Shared with Loveβ₯οΈ
Playground
Free AI Design Tool: Logos, T-Shirts, Social Media - Playground
Create custom designs and graphics with Playground
Wow π²
Ai Image Generator And Downloader
β’ For Free
β’ Without Background
β’ High Resolution
β’ .....
Ai Link π
https://playgroundai.com
@CodingCoursePro
Shared with Loveβ₯οΈ
Ai Image Generator And Downloader
β’ For Free
β’ Without Background
β’ High Resolution
β’ .....
Ai Link π
https://playgroundai.com
@CodingCoursePro
Shared with Loveβ₯οΈ
β€1
β€1