






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Covers: Syntax Data Types Control Flow Functions Classes Files Libraries
What is Python? Python is a popular high-level programming language known for its simple synt versatility. It is used in web development, data science, automation, artificial intellige and more.
2. Basics & Syntax
name = "Alice" # str age = 25 # int height = 5.7 # float is_student = True # bool
print(f"My name is {name}, I am {age} years old")
3. Data Types Numbers: int, float, complex String: "Hello" (immutable) List: [1, 2, 3] (mutable, ordered) Tuple: (1, 2, 3) (immutable, ordered) Dict: {"a": 1, "b": 2} (key-value) Set: {1, 2, 3} (unique, unordered) None: absence of value
5. Functions & Modules def greet(name: str) -> str: return f"Hello, {name}" print(greet("Alice"))
import math print(math.sqrt(16))
from random import randint print(randint(1, 10))
6. Classes & OOP class Dog: def init(self, name): self.name = name def bark(self): return f"{self.name} says woof!" d = Dog("Buddy") print(d.bark())
8. Popular Libraries NumPy numerical computing import numpy as np arr = np.array([1, 2, 3]) print(arr.mean()) Pandas data analysis import pandas as pd df = pd.DataFrame({"a":[1,2], "b":[3,4]}) print(df.head()) Matplotlib visualization import matplotlib.pyplot as plt plt.plot([1,2,3], [4,5,6]) plt.show() Requests web requests import requests r = requests.get("https://example.com") print(r.status_code)
9. Tips & Resources Use f-strings for formatting List comprehensions for cleaner loops Use virtual environments for projects Explore official docs: docs.python.org Practice on LeetCode, HackerRank, or Project Euler Great learning sites: Real Python, W3Schools, GeeksforGeeks