DEV Community

Cover image for Day 3/100: First Python Program — Hello, World! + input()
 Rahul Gupta
Rahul Gupta

Posted on

Day 3/100: First Python Program — Hello, World! + input()

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!")
Enter fullscreen mode Exit fullscreen mode

Now run it:

python hello.py
Enter fullscreen mode Exit fullscreen mode

You should see:

Hello, world!
Enter fullscreen mode Exit fullscreen mode

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!")
Enter fullscreen mode Exit fullscreen mode

Output:

Learning Python is fun!
Enter fullscreen mode Exit fullscreen mode

You can also print numbers:

print(2025)
print(5 + 10)
Enter fullscreen mode Exit fullscreen mode

🎤 Step 2: Taking User Input

Let’s make it interactive!

name = input("What's your name? ")
print("Nice to meet you,", name)
Enter fullscreen mode Exit fullscreen mode

Sample Output:

What's your name? Rahul
Nice to meet you, Rahul
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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!")
Enter fullscreen mode Exit fullscreen mode

Or:

city = input("Which city are you from? ")
print("Cool! I’ve heard", city, "is beautiful.")
Enter fullscreen mode Exit fullscreen mode

🚀 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)