Chapter 3 Beginner 60 Questions

Practice Questions — Your First Python Program

← Back to Notes
10 Easy
12 Medium
9 Hard

Topic-Specific Questions

Question 1
Easy
Write a Python program that prints: Hello, I am learning Python!
Use the print() function with the message inside quotes.
print("Hello, I am learning Python!")
Question 2
Easy
Write a Python program that prints the number 2026 (without quotes).
Numbers do not need quotes inside print().
print(2026)
Question 3
Easy
What is the difference between print(100) and print("100")?
One is a number and the other is text.
print(100) prints the integer 100. print("100") prints the string "100". The output looks the same on screen, but Python treats them differently — 100 is a number (you can do math with it) and "100" is text (a sequence of characters).
Question 4
Easy
What is the output of the following code? print("Python") print("is") print("fun")
Each print() statement outputs on a new line by default.
Output:
Python
is
fun
Question 5
Easy
What is the output of: print("My age is", 14)
When you separate values with commas, Python adds a space between them.
Output: My age is 14
Question 6
Easy
What does the escape character \n do inside a string?
The 'n' stands for 'new line'.
\n is the newline escape character. It moves the output to the next line.
Question 7
Medium
What is the output of: print("Hello\tWorld\nGoodbye\tWorld")
\t adds a tab space, \n moves to next line.
Output:
Hello	World
Goodbye	World
Question 8
Medium
What is the output of: print("A", "B", "C", sep="-")
The sep parameter replaces the default space between values.
Output: A-B-C
Question 9
Medium
What is the output of the following code? print("Hello", end=" ") print("World", end="!") print()
The end parameter controls what comes after the printed text instead of a newline.
Output: Hello World!
Question 10
Medium
Write a Python program that prints a file path: C:\Users\Sneha\Documents using proper escape characters.
You need to use \\ to print a single backslash.
print("C:\\Users\\Sneha\\Documents")
Question 11
Medium
What is the difference between # comments and ''' ''' (triple-quote) comments?
One is for single lines, the other can span multiple lines.
# creates a single-line comment — everything after # on that line is ignored. ''' ''' (triple quotes) create multi-line comments that can span multiple lines. Technically, triple-quoted strings are not true comments but strings that are not assigned to any variable, so they are discarded.
Question 12
Medium
What is the output of: print(10, 20, 30, sep=", ", end=".\n")
sep controls what goes between values, end controls what comes at the very end.
Output: 10, 20, 30.
Question 13
Hard
What is the output of the following code? print("She said", end=" ") print("\"Hello\"") print('It\'s', end=" ") print("a sunny day")
\" prints a literal double quote, \' prints a literal single quote.
Output:
She said "Hello"
It's a sunny day
Question 14
Hard
What is the output of: print("1", "2", "3", sep="\n") print() print("A", "B", "C", sep="\t")
sep="\n" means a newline is used as the separator between values.
Output:
1
2
3

A	B	C
Question 15
Hard
Write a single print() statement that produces this exact output: Name Marks Aarav 95 Meera 88
Use \n for new lines and \t for tabs, all inside one string.
print("Name\tMarks\nAarav\t95\nMeera\t88")
Question 16
Easy
What happens when you call print() with no arguments (empty parentheses)?
Think about what the default end character is.
An empty print() prints a blank line. Since print() has no values to display but still outputs the default end character (\n), it produces an empty line.
Question 17
Hard
Predict the output of: print("A", end="") print("B", end="") print("C", end="") print() print("Done")
end="" means nothing is printed after the value, not even a newline.
Output:
ABC
Done
Question 18
Medium
Write a program that prints a date in DD/MM/YYYY format using the sep parameter. Print 15, 08, and 2026 as separate values.
Use three numbers as separate arguments and set sep to '/'.
print(15, "08", 2026, sep="/")
Question 19
Hard
What is the output of: print("\\n")
The first backslash escapes the second backslash. Then 'n' is a regular character.
Output: \n

Mixed & Application Questions

Question 1
Easy
Write a program that prints your name, your class, and your favorite subject on three separate lines.
Use three separate print() statements.
print("Name: Vikram Singh")
print("Class: 9th Standard")
print("Favourite Subject: Mathematics")
Question 2
Easy
What is the output of: print(5, 10, 15, 20)
Multiple values separated by commas are printed with spaces between them.
Output: 5 10 15 20
Question 3
Medium
Explain why print debugging is useful and give an example of when you would use it.
Think about a situation where your program gives the wrong answer.
Print debugging is the technique of adding print() statements to your code to see the values of variables and expressions at different points during execution. For example, if a calculation gives 50 instead of the expected 100, you can add print() after each step to see where the value goes wrong: print("Step 1:", value1), print("Step 2:", value2), etc.
Question 4
Medium
Write a program that prints the following pattern using a single print() statement with escape characters: * ** *** ****
Use \n to move to the next line within a single string.
print("*\n**\n***\n****")
Question 5
Medium
Why is it important to write comments in your code? Give three reasons.
Think about future-you, other people reading your code, and debugging.
Three reasons: (1) Future reference: When you return to your code after weeks or months, comments remind you what each part does and why. (2) Collaboration: When other people read your code (classmates, teachers, team members), comments help them understand your logic without having to decode every line. (3) Debugging: You can "comment out" lines of code (add # before them) to temporarily disable them while testing, without deleting the code.
Question 6
Medium
What is the output of: print("5 + 3") print(5 + 3)
The first one has quotes (it is a string), the second does not (it is an expression).
Output:
5 + 3
8
Question 7
Hard
Write a program that uses only print() statements with the end parameter to print "HELLO" with each letter on the same line, separated by dots: H.E.L.L.O
Print each letter separately with end="." except for the last one.
print("H", end=".")
print("E", end=".")
print("L", end=".")
print("L", end=".")
print("O")
Question 8
Hard
What is the output of: print("Line 1", end="\n\n") print("Line 2", end="\n\n") print("Line 3")
end="\n\n" means two newlines — one normal and one extra blank line.
Output:
Line 1

Line 2

Line 3
Question 9
Hard
Predict the output of: print("A", "B", sep="", end="") print("C", "D", sep="", end="\n") print("E", "F", sep="-")
sep="" means no space between values. end="" means no newline.
Output:
ABCD
E-F
Question 10
Medium
What is a raw string in Python? When would you use it?
It starts with the letter 'r' before the quote. It treats backslashes as literal characters.
A raw string is prefixed with r before the opening quote: r"text". In a raw string, backslashes are treated as literal characters and not as escape characters. So r"\n" prints \n (two characters) instead of a newline. Raw strings are useful for file paths (like r"C:\new_folder") and regular expressions.
Question 11
Easy
Write a comment above the following line of code explaining what it does: print(2 ** 8)
The ** operator raises a number to a power. 2 ** 8 means 2 to the power of 8.
# Calculate and print 2 raised to the power of 8
print(2 ** 8)
Question 12
Hard
What is the output of: print(type("Hello")) print(type(42)) print(type(3.14))
The type() function tells you what data type a value is.
Output:


Multiple Choice Questions

MCQ 1
What is the correct way to print "Hello" in Python 3?
  • A. echo("Hello")
  • B. print("Hello")
  • C. display("Hello")
  • D. write("Hello")
Answer: B
B is correct. In Python, the print() function displays output. echo (Option A) is used in PHP and shell scripting. display (Option C) and write (Option D) are not standard Python output functions.
MCQ 2
Which of the following is a valid Python string?
  • A. Hello World
  • B. 'Hello World'
  • C. (Hello World)
  • D. [Hello World]
Answer: B
B is correct. Strings in Python must be enclosed in quotes (single or double). Option A has no quotes. Options C and D use parentheses and brackets, which have different meanings in Python (function calls and lists, respectively).
MCQ 3
What is the output of print(10 + 5)?
  • A. 10 + 5
  • B. 15
  • C. 105
  • D. Error
Answer: B
B is correct. Since 10 + 5 is without quotes, Python evaluates it as a mathematical expression (10 + 5 = 15) and prints the result. Option A would be the output of print("10 + 5") (with quotes). Option C would result from string concatenation, not numeric addition.
MCQ 4
What does \n represent in a Python string?
  • A. The letter 'n'
  • B. A backslash followed by 'n'
  • C. A newline (moves to next line)
  • D. A null character
Answer: C
C is correct. \n is the newline escape character. When Python sees \n in a string, it creates a line break. Option A is wrong — that would just be the character 'n'. Option B would be represented as \\n in Python (double backslash). Option D is wrong — the null character is \0.
MCQ 5
What symbol is used for single-line comments in Python?
  • A. //
  • B. /* */
  • C. #
  • D. --
Answer: C
C is correct. Python uses the hash symbol (#) for single-line comments. // (Option A) is used in JavaScript, Java, and C++. /* */ (Option B) is used for multi-line comments in C, Java, and JavaScript. -- (Option D) is used in SQL.
MCQ 6
What is the output of print('Hello') and print("Hello")?
  • A. Hello and 'Hello'
  • B. Both print Hello (same output)
  • C. 'Hello' and "Hello"
  • D. Error in one of them
Answer: B
B is correct. Single quotes and double quotes are interchangeable in Python for creating strings. Both print('Hello') and print("Hello") produce exactly the same output: Hello. The quotes are not part of the output — they only mark the beginning and end of the string in the code.
MCQ 7
What is the output of print("A", "B", "C", sep="*")?
  • A. A B C
  • B. A*B*C
  • C. ABC
  • D. A * B * C
Answer: B
B is correct. The sep parameter changes the separator between values from the default space to the specified string. sep="*" puts an asterisk between each value: A*B*C. Option A would be the output without the sep parameter. Option C would result from sep="". Option D would result from sep=" * ".
MCQ 8
What does the end parameter in print() control?
  • A. The last value that gets printed
  • B. Whether the program ends after printing
  • C. What character is printed after the output (default is newline)
  • D. The ending quote of the string
Answer: C
C is correct. The end parameter specifies what character (or string) is added after all values are printed. The default is '\n' (newline), which is why each print() normally starts on a new line. Setting end=" " makes the next print() continue on the same line with a space. Option A is wrong — end does not affect what values are printed. Option B is wrong — end has nothing to do with program termination.
MCQ 9
Which escape character adds a horizontal tab in a string?
  • A. \n
  • B. \t
  • C. \s
  • D. \h
Answer: B
B is correct. \t is the tab escape character that adds horizontal spacing. \n (Option A) is a newline. \s (Option C) is not a valid Python escape character. \h (Option D) is not a valid Python escape character either.
MCQ 10
What is the output of print("Hello\\World")?
  • A. HelloWorld
  • B. Hello\World
  • C. Hello\\World
  • D. Hello\nWorld
Answer: B
B is correct. The double backslash (\\) is an escape sequence that produces a single literal backslash (\) in the output. So "Hello\\World" prints Hello\World. Option A would result from print("Hello" + "World"). Option C shows the code, not the output. Option D would result from print("Hello\nWorld").
MCQ 11
What is the output of print("5" + "3")?
  • A. 8
  • B. 53
  • C. 5 3
  • D. Error
Answer: B
B is correct. When you use + with strings, Python concatenates (joins) them together. "5" + "3" joins the string "5" and the string "3" to get "53". This is NOT mathematical addition. Option A (8) would be the output of print(5 + 3) (without quotes — numeric addition).
MCQ 12
Which of the following correctly prints: It's a great day
  • A. print('It's a great day')
  • B. print("It's a great day")
  • C. print(It's a great day)
  • D. print("Its a great day")
Answer: B
B is correct. Since the string contains an apostrophe (single quote), wrapping it in double quotes avoids confusion. Option A causes a SyntaxError because the apostrophe in It's closes the single-quoted string prematurely. Option C has no quotes at all. Option D removes the apostrophe, changing the text.
MCQ 13
What is the output of: print("X", end="") print("Y", end="") print("Z")
  • A. X Y Z
  • B. XYZ
  • C. X\nY\nZ
  • D. X Y Z
Answer: B
B is correct. The first two print() calls have end="" (empty string), which means no character is added after the output — not even a space or newline. So X, Y, and Z are printed directly next to each other: XYZ. The last print("Z") uses the default end="\n", which ends the line.
MCQ 14
What is the output of print("Line1\nLine2\nLine3")?
  • A. Line1\nLine2\nLine3
  • B. Line1 Line2 Line3
  • C. Line1 Line2 Line3
  • D. Line1nLine2nLine3
Answer: C
C is correct. Each \n in the string creates a newline, so the three words appear on three separate lines. Option A would be the output of a raw string: print(r"Line1\nLine2\nLine3"). Option B would result if \n were replaced with spaces. Option D would result if the backslashes were removed.
MCQ 15
Which of the following is NOT a valid escape sequence in Python?
  • A. \n
  • B. \t
  • C. \a
  • D. \p
Answer: D
D is correct. \p is not a recognized escape sequence in Python. \n (newline), \t (tab), and \a (bell/alert sound) are all valid escape sequences. When Python encounters an unrecognized escape sequence like \p, it treats the backslash as a literal character in newer versions, but this is not reliable behavior.
MCQ 16
What is the output of print("\\n")?
  • A. A newline (blank line)
  • B. \n
  • C. \\n
  • D. n
Answer: B
B is correct. The first two backslashes (\\) form an escape sequence that produces a single literal backslash (\). The 'n' after it is just a regular character. So the output is the two characters: \n. This is different from a single \n which would produce a newline. Option A would be the output of print("\n").
MCQ 17
What is the output of print(type("42"))?
  • A. <class 'int'>
  • B. <class 'str'>
  • C. <class 'float'>
  • D. 42
Answer: B
B is correct. "42" is enclosed in quotes, making it a string (str), not a number. The type() function returns the data type. Without quotes, type(42) would return . The quotes make all the difference — "42" is text, while 42 is a number.
MCQ 18
What is the output of print(1, 2, 3, sep="\t", end="!\n")?
  • A. 1 2 3!
  • B. 1\t2\t3!
  • C. 1 2 3!
  • D. 123!
Answer: C
C is correct. sep="\t" puts a tab character between each value (1, 2, 3), and end="!\n" adds an exclamation mark followed by a newline at the end. The output is: 1[tab]2[tab]3! Option A would result from the default sep (space). Option B shows the raw code, not the interpreted output. Option D would result from sep="".
MCQ 19
How do you write a multi-line comment in Python?
  • A. /* This is a comment */
  • B. // This is a comment
  • C. ''' This is a comment '''
  • D. <!-- This is a comment -->
Answer: C
C is correct. Python uses triple quotes (''' or """) for multi-line comments/strings. /* */ (Option A) is used in C, Java, JavaScript. // (Option B) is a single-line comment in C, Java, JavaScript. (Option D) is used in HTML.
MCQ 20
What is the default separator between values in print()?
  • A. No separator
  • B. A comma
  • C. A space
  • D. A newline
Answer: C
C is correct. The default value of the sep parameter is a single space (" "). So print("A", "B") outputs "A B" with a space between them. Option A would be sep="". Option B would be sep=",". Option D would be sep="\n".
MCQ 21
What happens if you write: print('She said 'Hi'')?
  • A. It prints: She said Hi
  • B. It prints: She said 'Hi'
  • C. It causes a SyntaxError
  • D. It prints: She said 'Hi
Answer: C
C is correct. Python sees the first single quote as the start of the string and the second single quote (before Hi) as the end. The remaining Hi'' is invalid Python syntax, causing a SyntaxError. To fix this, use double quotes on the outside: print("She said 'Hi'") or escape the inner quotes: print('She said \'Hi\'').

Coding Challenges

Challenge 1: Personal Introduction

Easy
Write a Python program that prints your name, age, city, and favourite hobby on four separate lines.
Sample Input
(No input required)
Sample Output
Name: Kavya Joshi Age: 13 City: Pune Hobby: Reading books
Use four separate print() statements. Each line should have a label followed by the information.
print("Name: Kavya Joshi")
print("Age: 13")
print("City: Pune")
print("Hobby: Reading books")

Challenge 2: Formatted Table

Easy
Write a program that prints a multiplication table for 5 (from 5x1 to 5x5) using tab escape characters for neat alignment.
Sample Input
(No input required)
Sample Output
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25
Use \t for alignment. Let Python calculate the results (do not hardcode the answers).
print("5 x 1\t=\t", 5 * 1)
print("5 x 2\t=\t", 5 * 2)
print("5 x 3\t=\t", 5 * 3)
print("5 x 4\t=\t", 5 * 4)
print("5 x 5\t=\t", 5 * 5)

Challenge 3: Date Formatter

Medium
Write a program that prints today's date in three different formats using the sep parameter: DD-MM-YYYY, DD/MM/YYYY, and DD.MM.YYYY. Use 06, 04, and 2026 as the day, month, and year.
Sample Input
(No input required)
Sample Output
06-04-2026 06/04/2026 06.04.2026
Use the sep parameter in each print() call. Do not use string concatenation.
print("06", "04", "2026", sep="-")
print("06", "04", "2026", sep="/")
print("06", "04", "2026", sep=".")

Challenge 4: Loading Animation

Medium
Write a program that simulates a loading animation by printing 'Loading' followed by 10 dots on the same line, then 'Done!' on the same line. Use the end parameter.
Sample Input
(No input required)
Sample Output
Loading..........Done!
Use multiple print() statements with end="" to keep everything on one line. Print each dot separately.
print("Loading", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print(".", end="")
print("Done!")

Challenge 5: Student Report Card with Comments

Medium
Write a well-commented program that creates a formatted report card for a student. Include at least 5 subjects with marks, calculate the total using Python, and use tabs for alignment. Every section must have a comment explaining it.
Sample Input
(No input required)
Sample Output
============================= REPORT CARD - Class 9 ============================= Name: Arjun Reddy Roll: 15 Subject Marks ------- ----- Maths 92 Science 88 English 95 Hindi 82 Computer 97 Total: 454 / 500 =============================
Include at least 8 comments explaining different parts of the code. Use \t for alignment. Calculate the total using Python arithmetic.
# Student Report Card Program
# This program displays a formatted report card

# Header section
print("=============================")
print("    REPORT CARD - Class 9")
print("=============================")

# Student information
print("Name:\tArjun Reddy")
print("Roll:\t15")
print()  # Blank line for spacing

# Table header
print("Subject\t\tMarks")
print("-------\t\t-----")

# Individual subject marks
print("Maths\t\t92")
print("Science\t\t88")
print("English\t\t95")
print("Hindi\t\t82")
print("Computer\t97")
print()

# Total calculation - let Python do the math
print("Total:\t\t", 92 + 88 + 95 + 82 + 97, "/ 500")
print("=============================")

Challenge 6: Escape Character Art

Hard
Write a program using ONLY a single print() statement (with escape characters) that produces this exact output: Name: "Diya" Path: C:\Users\Diya Status: It's working! Note: Use \n for new lines, \" for quotes, \\ for backslash, and \' for apostrophe.
Sample Input
(No input required)
Sample Output
Name: "Diya" Path: C:\Users\Diya Status: It's working!
Must use ONLY ONE print() statement. Must use at least three different escape characters.
print("Name: \"Diya\"\nPath: C:\\Users\\Diya\nStatus: It\'s working!")

Challenge 7: sep and end Mastery

Hard
Write a program that uses the sep and end parameters creatively to print the following output. You must use at least 5 print() statements, each using either sep or end (or both). Expected output: IP: 192.168.1.1 Date: 06/04/2026 Time: 10:30:45 Path: C > Users > Student > Code Status: OK...DONE!
Sample Input
(No input required)
Sample Output
IP: 192.168.1.1 Date: 06/04/2026 Time: 10:30:45 Path: C > Users > Student > Code Status: OK...DONE!
Each print() must use sep and/or end parameters. Do not concatenate strings manually.
print("IP:", end=" ")
print(192, 168, 1, 1, sep=".")
print("Date:", end=" ")
print("06", "04", "2026", sep="/")
print("Time:", end=" ")
print(10, 30, 45, sep=":")
print("Path:", end=" ")
print("C", "Users", "Student", "Code", sep=" > ")
print("Status: OK", end="")
print(".", end="")
print(".", end="")
print(".DONE!")

Challenge 8: ASCII Art with Print

Hard
Create an ASCII art house using only print() statements. The house should have a triangular roof, rectangular walls, and a door. It should be at least 7 lines tall.
Sample Input
(No input required)
Sample Output
/\ / \ / \ /______\ | | | [] | | || | |__||__|
Use print() statements. The house must have a recognizable roof, walls, and door. Minimum 7 lines.
print("     /\\")
print("    /  \\")
print("   /    \\")
print("  /______\\")
print("  |      |")
print("  |  []  |")
print("  |  ||  |")
print("  |__||__|")

Challenge 9: Complete Program with All Concepts

Hard
Write a program that serves as a Python cheat sheet for the print() function. It should demonstrate: basic printing, numbers, escape characters (\n, \t, \\, \"), sep parameter, end parameter, comments, and an empty print(). Include a title, section headers, and examples with their expected output shown as comments.
Sample Input
(No input required)
Sample Output
=== Python print() Cheat Sheet === 1. Basic String: Hello, World! 2. Number: 42 3. Multiple Values: Python is fun 4. Escape Characters: Line1 Line2 Name Age Path: C:\Users She said "Hi" 5. sep Parameter: 2026-04-06 6. end Parameter: A B C Done! === End of Cheat Sheet ===
Must demonstrate all 6 concepts listed. Include comments explaining each section. Output must be neatly formatted with section numbers.
# Python print() Cheat Sheet
# Demonstrates all features of the print() function

print("=== Python print() Cheat Sheet ===")
print()

# 1. Basic string printing
print("1. Basic String:")
print("Hello, World!")
print()

# 2. Printing numbers
print("2. Number:")
print(42)
print()

# 3. Multiple values
print("3. Multiple Values:")
print("Python", "is", "fun")
print()

# 4. Escape characters
print("4. Escape Characters:")
print("Line1\nLine2")        # \n for new line
print("Name\tAge")          # \t for tab
print("Path: C:\\Users")    # \\ for backslash
print("She said \"Hi\"")   # \" for double quote
print()

# 5. sep parameter
print("5. sep Parameter:")
print(2026, "04", "06", sep="-")
print()

# 6. end parameter
print("6. end Parameter:")
print("A", end=" ")
print("B", end=" ")
print("C", end=" ")
print("Done!")
print()

print("=== End of Cheat Sheet ===")

Need to Review the Concepts?

Go back to the detailed notes for this chapter.

Read Chapter Notes

Want to learn Python with a live mentor?

Explore our Python course