Python Cheatsheet ♥️
1. Common Data Types
int, float – numbers
str – text
list – ordered, changeable collection
dict – key-value pairs
tuple – like list, but unchangeable
set – unique, unordered items
2. Essential Functions
print() – display output
type() – check data type
len() – count items
range() – generate numbers
input() – take user input
3. String Methods
.upper(), .lower() – change case
.strip() – remove whitespace
.replace() – swap text
.split() – break into list
4. List Methods
append() – add item
pop() – remove item
sort() – sort list
[1:4] – slicing (get part of list)
5. Dictionary Basics
Access: mydict['key']
Safe access: mydict.get('key')
Add/Update: mydict['new'] = value
6. Control Flow
if / elif / else – conditions
for – loop over items
while – loop with condition
break / continue – control loop
7. Functions
def – define a function
return – return a value
lambda – short anonymous function
8. Useful Built-in Modules
math – sqrt, pi, round
random – random numbers, choices
datetime – current date/time
os – system & file handling
9. Popular Libraries for Data Work
NumPy – numerical operations
Pandas – dataframes and analysis
Matplotlib
React with ❤️ for more useful Cheatsheets
#python
Post #2359
1.59K
- ❤ 7