Python is a high-level, interpreted programming language known for its readability and ease of use.
It is widely used in web development, data science, AI, and scripting tasks.
print("Hello, Python!")
- Easy to learn
- Open-source
- Community support
Variables store information in Python. You do not need to declare the type explicitly.
Use the assignment operator (=) to assign values.
x = 10
name = "Alice"
- Dynamic typing
- Reassign anytime
Python supports multiple built-in data types such as integers, floats, strings, lists, and dictionaries.
You can check data types with the type()
function.
type(42) # int
type(3.14) # float
type("Hi") # str
- int
- float
- str
- list
- dict
Python uses indentation instead of braces for blocks.
Control structures include if/else, for loops, and while loops.
if x > 5:
for i in range(3):
while condition:
- If statements
- For loops
- While loops
Functions are defined using the def
keyword.
They help organize reusable blocks of code.
def greet(name):
return "Hello " + name
- Parameters
- Return values
Modules allow you to organize Python code across multiple files.
You can import built-in or custom modules.
import math
print(math.sqrt(16))
- Standard Library
- Third-party modules