1. Introduction to Python
Python is a high-level, interpreted programming language created by Guido van Rossum in 1991. Known
for its simplicity and readability, Python is used in web development, data science, artificial intelligence,
scientific computing, and more.
Key Features of Python:
Easy to Learn: Its simple syntax resembles natural language.
Interpreted: Python code is executed line by line.
Dynamically Typed: No need to declare variable types explicitly.
Extensive Libraries: Python has a vast collection of libraries like NumPy, pandas, TensorFlow, etc.
Portability: Python is platform-independent, running on Windows, macOS, Linux, etc.
2. Python Basics
2.1 Python Syntax
python
Copy code
# A simple Python program
print("Hello, World!") # Output: Hello, World!
2.2 Variables
Variables are used to store data. No need for explicit type declarations.
python
Copy code
x = 10 # Integer
y = 3.14 # Float
name = "Python" # String
is_active = True # Boolean
2.3 Data Types
Numeric Types: int, float, complex
, Sequence Types: list, tuple, range
Text Type: str
Set Types: set, frozenset
Mapping Type: dict
Boolean Type: bool
Binary Types: bytes, bytearray, memoryview
2.4 Input and Output
python
Copy code
name = input("Enter your name: ") # Taking input
print(f"Hello, {name}!") # Output: Hello, User!
3. Control Structures
3.1 Conditional Statements
python
Copy code
age = 18
if age >= 18:
print("You are an adult.")
elif age > 12:
print("You are a teenager.")
else:
print("You are a child.")
3.2 Loops
for Loop:
python
Copy code
for i in range(1, 6):
print(i) # Output: 1 2 3 4 5