Welcome back to Day 3 of the 100 Days of Python series!
Yesterday, we installed Python and set up our coding environment. Today, we’re writing our first real Python programs using print()
and input()
— two essential building blocks for any interactive script.
Let’s get started. 🚀
📦 What You'll Learn Today
- How to write and run your first Python program
- The
print()
function - The
input()
function - How to write comments
- A simple interactive example
🧪 Step 1: Your First Program
Create a new file called hello.py
, and type this:
print("Hello, world!")
Now run it:
python hello.py
You should see:
Hello, world!
Congrats — you just wrote and ran your first Python program! 🎉
🧠 What Just Happened?
print()
is a built-in Python function. It displays whatever you put inside the parentheses to the screen.
print("Learning Python is fun!")
Output:
Learning Python is fun!
You can also print numbers:
print(2025)
print(5 + 10)
🎤 Step 2: Taking User Input
Let’s make it interactive!
name = input("What's your name? ")
print("Nice to meet you,", name)
Sample Output:
What's your name? Rahul
Nice to meet you, Rahul
Here’s what’s happening:
-
input()
waits for the user to type something - Whatever they type gets stored in the variable
name
- Then
print()
shows a message using that value
💬 Pro Tip: Comments
Comments are lines Python ignores. They help you and others understand what your code does.
# This prints a greeting message
print("Hello there!") # inline comment
Use comments to explain tricky logic or make your code more readable.
🧪 Bonus: Combine Input + Logic
Try this fun challenge:
age = input("How old are you? ")
print("Wow, you're", age, "years old!")
Or:
city = input("Which city are you from? ")
print("Cool! I’ve heard", city, "is beautiful.")
🚀 Recap
Today you learned:
- How to use
print()
to show output - How to use
input()
to collect user input - How to store and use variables
- How to write comments for clarity
Top comments (0)