


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!



•High-level programming language (easy to understand). •Interpreted (executed line by line). •Dynamically typed (no need to declare variable types). •Portable (runs on different platforms: Windows, Linux, macOS). •Open-source and widely used in web development, data science, AI, automation, etc.
Comments:
""" Multi-line comment """
print("Hello, World!")
No need to declare type explicitly:
x = 10 # Integer y = 3.14 # Float name = "Adi" # String flag = True # Boolean
type(x) #
A) Strings
s = "Python" print(s[0]) # P print(s[-1]) # n
print(s[0:4]) # Pyth
B) Lists (mutable, ordered)
nums = [1, 2, 3, 4] nums.append(5) nums[0] = 10
C) Tuples (immutable, ordered)
t = (1, 2, 3)
D) Sets (unordered, unique values)
s = {1, 2, 2, 3} print(s) # {1, 2, 3}
E) Dictionaries (key-value pairs)
d = {"name": "Adi", "age": 20} print(d["name"]) # Adi
Operators
Arithmetic: + - * / % // ** Comparison: == != > < >= <= Logical: and or not Membership: in, not in Identity: is, is not
x = 10 if x > 0: print("Positive") elif x == 0: print("Zero") else: print("Negative")
For Loop:
with open("data.txt", "w") as f: f.write("Hello Python")
with open("data.txt", "r") as f: print(f.read())
NumPy → Numerical computing
Pandas → Data analysis
Matplotlib → Data visualization
Scikit-learn → Machine Learning
TensorFlow / PyTorch → Deep Learning
Flask / Django → Web development