One of the most common question types in Class 11 and 12 Computer Science board exams is: 'What will be the output of the following Python code?' These questions test whether you can mentally trace through code step by step without running it on a computer.
In Python, the print() function by default adds a newline character at the end. Using print(x, end='') or print(x, end=' ') changes this behavior — a very common source of tricky output questions!
Follow this systematic approach:
Example 1 — Simple Loop:
for i in range(1, 5):
print(i * 2)
Output:
2
4
6
8
(range(1,5) gives 1,2,3,4 — 5 is excluded)
Example 2 — String Slicing:
s = 'PYTHON'
print(s[1:4])
print(s[::-1])
Output:
YTH
NOHTYP
(s[1:4] → characters at index 1,2,3; s[::-1] → reversed string)
Example 3 — Nested Loop:
for i in range(1, 4):
for j in range(1, 4):
print(i * j, end=' ')
print()
Output:
1 2 3
2 4 6
3 6 9
range(n) gives 0 to n-1, NOT 0 to n7//2 = 3 (not 3.5)**1024**. The `**` operator is Python's exponentiation (power) operator. 2¹⁰ = 1024.
The Communication Process: Diagram and Elements
Understand the communication process diagram. Learn about the 7 key elements: Sender, Encoding, Message, Channel, Receiver, Decoding, and Feedback.
Why is Computer Called an Electronic Device?
Why is a computer called an electronic device? Learn the basic definition of a computer, how it processes data, and relies on electrical components.
कंप्यूटर कितने प्रकार के होते हैं? (Types of Computers in Hindi)
जानिए कंप्यूटर कितने प्रकार के होते हैं (Types of computers)। Micro, Mini, Mainframe, और Supercomputer के बीच का अंतर हिंदी में समझें।
Top 20 Computer Related Full Forms for Exams
A complete list of the most important computer-related full forms. Learn the full forms of CPU, RAM, ROM, HTTP, USB, and GUI for basic computer exams.
Computer Science Class 12 Syllabus Overview
Explore the CBSE Computer Science Class 12 syllabus. Learn about Python programming, SQL databases, and computer networks essential for board exams.
Turn this guide into revision flashcards, a practice exam, or an AI-generated podcast — free, no signup required.