-
Hajipur, Bihar, 844101
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.
Open IDLE.
Click on File > New File.
Type the following code:
print("Hello, World!")
Save the file with a .py
extension (e.g., first_program.py
).
Press F5 to run the program.
Hello, World!
Open VS Code.
Create a new file named first_program.py
.
Type the same code:
print("Hello, World!")
Open the terminal inside VS Code (Ctrl +
`).
Run the file:
python first_program.py
Hello, World!
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")
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") |
print("Python is awesome!")
print("My name is John")
print(5 + 7)
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.
Q1: What is the correct way to print in Python 3?
Q2: What is the output of print(2 + 3)?
Q3: Which of the following is a valid string?
Q4: What does print("Hi" * 3) display?
Q5: Python is case-sensitive. What is the result of Print("Hello")?
Q6: What type of function is print() in Python?
Q7: Which symbol is used to enclose string literals?
Q8: What will print("5" + "5") output?
Q9: Which of these is the correct file extension for Python?
Q10: What happens if you omit the parentheses in print in Python 3?