Resources, Internship & Job Updates | iamrupnath
Resources, Internship & Job Updates | iamrupnath
June 13, 2025 at 02:02 AM
*Python Cheatsheet* 🐍 This Cheatsheet covers the core Python concepts everyone should know. *1. Basics* print() – Outputs text to the screen. Comments – Use # for single-line and triple quotes """ for multi-line comments. print("Hello") # This will print Hello *2. Variables & Data Types* Variables store values of different types like numbers, strings, booleans, lists, etc. x = 10 # Integer name = "Alice" # String flag = True # Boolean *3. Conditionals* Used to make decisions in code using if, elif, and else. if x > 0: print("Positive") else: print("Not positive") *4. Loops* - For loop: Iterates over a sequence. - While loop: Repeats as long as a condition is true. for i in range(3): print(i) *5. Functions* A reusable block of code defined with def. def greet(name): return "Hello " + name *6. Lists & List Comprehension* - Lists: Store multiple items in one variable. - List comprehension: Short way to create lists. nums = [1, 2, 3] squares = [x**2 for x in nums] *7. Dictionaries* Key-value pairs, like a mini-database. user = {"name": "Bob", "age": 25} print(user["name"]) *8. String Methods* Strings are text, and Python provides handy methods to manipulate them. s = "hello" print(s.upper()) # "HELLO" print(s.replace("e", "a")) # "hallo" *9. File Handling* Read and write files using open(). with open("file.txt", "w") as f: f.write("Hi there!") *10. Error Handling* Prevents your program from crashing with try, except, and finally. try: x = 10 / 0 except: print("Error occurred") *11. Classes & Objects* Used in Object-Oriented Programming to create reusable code structures. class Dog: def __init__(self, name): self.name = name *12. Useful Built-in Functions* Handy tools built into Python. len(), type(), sum(), min(), max(), sorted() *React ❤️ for the detailed explanation of each Python concept*
❤️ 13

Comments