Python First Program


Once Python is installed and your editor (IDLE or VS Code) is set up, it's time to write your first Python program.

Python is known for its simplicity and readable syntax. Let’s create a basic script that prints something on the screen — the traditional way to begin is with a Hello, World! program.


🖥️ Writing Your First Python Program

✅ Using IDLE

  1. Open IDLE.

  2. Click on File > New File.

  3. Type the following code:

    print("Hello, World!")
    
  4. Save the file with a .py extension (e.g., first_program.py).

  5. Press F5 to run the program.

✅ Output

Hello, World!

✅ Using VS Code

  1. Open VS Code.

  2. Create a new file named first_program.py.

  3. Type the same code:

    print("Hello, World!")
    
  4. Open the terminal inside VS Code (Ctrl + `).

  5. Run the file:

    python first_program.py
    

✅ Output

Hello, World!

🧠 How Does It Work?

The print() function is used to display output in Python.
It takes one or more arguments and writes them to the standard output (usually the screen).

Syntax:

print(object(s), sep=separator, end=end, file=file, flush=flush)

For now, just remember:

print("any message you want to show")

❗ Common Mistakes

Mistake Example Fix
Missing quotes print(Hello World) print("Hello World")
Wrong function name Print("Hello") print("Hello") (Python is case-sensitive)
No parentheses (in Python 3) print "Hello" print("Hello")

💡 More Examples

print("Python is awesome!")
print("My name is John")
print(5 + 7)

Practice Questions

Q1. Write a Python program to print "Welcome to Python Programming".

Q2. Write a Python program to print your name using the print() function.

Q3. Write a Python program to print your age using the print() function.

Q4. Write a Python program to display the result of 5 + 10.

Q5. Write a Python program to show the output of print(3 * 7).

Q6. Write a Python program that prints your city and country.

Q7. Write a Python program to print the sentence: "Python is easy to learn."

Q8. Write a Python program to print two numbers on the same line.

Q9. Write a Python program to display your favorite quote using print().

Q10. Write a Python program to print your full name using two separate print() statements.



Python First Program Quiz

Q1: What is the correct way to print in Python 3?

A. print "Hello"
B. echo "Hello"
C. print("Hello")
D. printf("Hello")

Q2: What is the output of print(2 + 3)?

A. 2 + 3
B. 23
C. 5
D. Error

Q3: Which of the following is a valid string?

A. 'Hello'
B. "Hello"
C. """Hello"""
D. All of the above

Q4: What does print("Hi" * 3) display?

A. Hi3
B. HiHiHi
C. 3Hi
D. Error

Q5: Python is case-sensitive. What is the result of Print("Hello")?

A. Hello
B. print("Hello")
C. Error
D. Nothing

Q6: What type of function is print() in Python?

A. User-defined
B. Built-in
C. Module
D. Keyword

Q7: Which symbol is used to enclose string literals?

A. ''
B. ""
C. ''' '''
D. All of the above

Q8: What will print("5" + "5") output?

A. 10
B. 55
C. Error
D. 5 + 5

Q9: Which of these is the correct file extension for Python?

A. .py
B. .pt
C. .pyth
D. .exe

Q10: What happens if you omit the parentheses in print in Python 3?

A. It works fine
B. It prints nothing
C. It gives an error
D. It prints “print”

Go Back Top