Lesson 1: Python Basics
1.1 Introduction to Python
Python is a powerful, easy-to-learn programming language widely used in web development, data science, automation, and more. It is known for its simple syntax, making it a great first language for beginners.
1.2 Why Learn Python?
- Easy to Read and Write: Python’s syntax is intuitive and close to human language.
- Versatile: Used in web development, AI, data science, automation, and more.
- Large Community: Extensive support and libraries available.
- Beginner-Friendly: Ideal for new programmers due to its readability.
Writing Your First Python Program
On VS Code or Replit create a new file called HelloWorld.py and type:
print("Hello, World!")
This prints Hello, World! to the screen, a traditional first program.
1.4 Understanding Variables and Data Types
Variables: A variable stores a value that can change.
name = "Alice"
age = 25
print(name, age)
Data Types:
- Integers (
int
): Whole numbers (e.g.,10
,-5
). - Floats (
float
): Decimal numbers (e.g.,3.14
,-0.5
). - Strings (
str
): Text (e.g.,'Hello'
,"Python"
). - Booleans (
bool
):True
orFalse
.
1.5 Basic Operations
Python supports basic mathematical operations:
x = 10
y = 5
print(x + y) # Addition
print(x - y) # Subtraction
print(x * y) # Multiplication
print(x / y) # Division