1
Lesson 1
What is Python?
Python is a programming language that helps you give instructions to a computer to do tasks. Imagine it as learning a new language to talk to your computer!
It’s popular because:
- Easy to learn: Python reads almost like English, so it’s beginner-friendly.
- Versatile: You can use it to create websites, analyze data, make games, control robots, or even automate boring tasks.
Why Choose Python?
-
Clean and simple syntax: You can write less code to get things done.
- Large community: Lots of people use Python, so there are tons of free tutorials, tools, and libraries (pre-built code you can reuse).
- Fun to use: You can quickly see results, which makes it exciting for beginners!
Let’s Write Your First Python Program!
A program is just a set of instructions. Here's an example:
Open our Python online editor and type this:
print("Hello, world!")
When you run it, your computer will display:
Hello, world! You just wrote your first program! 🎉
Key concepts in Python
Variables:
These are like containers where you store data.
name = "Alice" age = 25 print(name, "is", age, "years old.")
Output:
Alice is 25 years old.
Data Types:
Python can handle different kinds of data:
-
Text: "Hello"
- Numbers: 42 (integers) or 3.14 (floats)
- True/False: True or False
- Lists: [1, 2, 3]
Control Flow:
Make decisions with if statements or repeat actions with loops.
if age > 18: print("You're an adult.") else: print("You're a minor.")
Functions:
Think of these as reusable "mini-programs."
def greet(name): print("Hi,", name) greet("Alice") greet("Bob")
Output:
Hi, Alice Hi, Bob
What Can You Do With Python as a Beginner?
-
Create simple programs like a calculator.
- Analyze data or work with spreadsheets.
- Automate tasks (e.g., renaming files, sending emails).
- Build small games or apps.
Python is like learning a superpower. It might seem tricky at first, but with practice, you'll be amazed at what you can create.