12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Economics Government Budget and the Economy Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Interface Python with MySQL - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Database Concept - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Communication - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Structures - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Functions - New Previous year Question Papers Study Material - QB365 Set A

Published on: 20/08/2026
Download CBSE Class 12th Standard CBSE Computer Science question papers, sample papers, important questions, and previous year solved papers in PDF format. Get free study materials, NCERT solutions, and exam preparation resources for Class 12th Standard CBSE Computer Science
Questions + Answers key
Take MCQ Computer Science Test

1.
Differentiate between break and continue statement with the help of an example.
2.
Write a program to print negative, zero or positive according to whether variable x is less than zero, zero or greater than zero respectively.
3.
Write a program to read a number. If the number is even print half the number otherwise print the next number. End your program by printing "Thank You".
4.
Python is dynamic typed. Explain it.
5.
Predict the output:
(i) a = 3
b =a *2
print(a*3+6+b)
(ii) a, b = 12, 10
c=a// b + 4 * 2
d = c - 10
print(d)
(iii) a = 5
b = 6
print((a and b)
or (a > b) )
(iv) a = 4
b = 6
c = 10
print(a >= b)
or ( (c = - b)
and (not(c < a))))
(v) a = 4
b = 6
c = 10
print ( (a <= b)
and print(c)
((c == a) and
(not(c < b))))
(vi) a = 60
b = 10
c = 85 / b + a
print(int(c))
(vii) a = 3
b = 4
c = a ** b + 5
print(c)
(viii) b = 89
a = 78
c = (a <= b)
print(c)
6.
Evaluate the following expressions..
(i) A=10* 4//2+4-2// 2 + 4 - 3 +5//8
(ii) A=5+6//3+10* 3// 4 + 2 +3//4
(iii) A=5* 5+4// 5 + 15-9//2+10
7.
Determine which of the arithmetic expressions are valid. If invalid, explain the reason. [(a, b, c) are integers, (p, q, r) are float and (x, y, z) are float].
(i) p / q + a - c
(ii) q (a + b - z / 4)
(iii) p / q + a - c
(iv) x / y + p * a/b
(v) a * + b
(vi) a +b*c*2
8.
Define the following terms
(i) Comments
(ii) Variables
(iii) Data Types
9.
Asish has written the following code, but he is getting some errors while executing it. Rewrite the correct code removing all the errors.
value=30
for val in range (0, value)
if u = 0 print (val + 4)
else if vals == 0;
print (val + 3)
else
print (val + 10)
10.
What will be the output of the following code? Explain how the jump statements affect the flow.
for i in range(1, 8) :
if 1% 20 == 0 :
continue
if i == 7:
break
print(i, end=" ")
11.
Find the output of the following code:
num-123
f=0
S=0
while (num > 3) :
rem = num % 100
if (rem % 2 ! = 0 ):
f + = rem
else:
s + = rem
num/ =100
print (f-s)
12.
Write a Python program that reads numbers from 1 to 10 using a loop, but stops the loop immediately when it encounters the number 7. Display the numbers printed before termination.
13.
Rewrite the following code into for loop:
i = 3
while (i < 5)
if (i = = 4) :
print ("Welcome")
else: print ("No entry")
i - i + 1
print ("value of i", i)
14.
What will be printed on the console by the below code:
x, y, z, k, j = 9, 7, 2, 2, 1
m = 5
if (x > y) :
if ( y > z and y > k):
m. = m - l
else:
k = k + 1
else:
j = j + l
print ( 'm =', m)
print ('k=', k)
print (' j =', j)
15.
Draw a flow chart to find the factorial of any number.
16.
Write an algorithm to find out whether the given number is divisible by 3 or not.
17.
Construct logical expressions to represent the following conditions.
(i) Weight is greater than or equal to 115 but less than 125.
(ii) Donation is in the range of 4000-5000 or Guest is 1.
18.
Predict the output.
a, b = 10.15
x = 20
y = 25
a = x + y - b
x = a + b - y + 10
z=y+b * 3 + a
x = 50
a = x + y + z
print("a : ",a)
print("b: " ,b)
print (" x : " ,x)
print (" y :" ,y)
print (" z : " ,z)
19.
What is the output of the following code:
>>> a = 10
>>> b =2
>>> print(" Output is ", (a + 10 * 2 + b))
20.
What will be the output of the following code?
a, b= 10, 5
X, y = a + b, b - 2
z = x - y
print ("x:", x, "y:", y, "z:", z)
21.
What is the output of the following code ?
num=4+float(7)/int(2.0)
print ("num=", num)
22.
Predict the output of the following program.
a = 5
b = a = 15
c = (a < 15)
print "a = ", a)
print ("b = ", b)
print ("c = ", c)
23.
What value will be stored in different variables. when the following Python statements are executed?
i = 10
j = i + 5
k = 1 + j / 5
l = k + 1 + 4
m = 2
n =k + m*l
print("i: ", i)
print("j: ", j)
print("k: ", k)
print("l: ", l)
print("m: ", m)
print("n: ", n)
24.
Determine the hierarchy of operations and evaluate following expression.
A=3*4//5+5// 7+8- 2+4//2.
25.
Write the value stored in the variable Num by each of the following statements.
(i) Num=2*3-4
(ii) Num=2+3-1*3
(iii) Num (2+3)*2
26.
Differentiate between identifier and keyword.
27.
Write a program to check whether a number is palindrome number or not.
(A palindrome number is one which is same as its reverse)
28.
Write a program to print the following pattern.
*
**
***
****
*****
29.
Write a Python program to generate and display all the armstrong numbers between 1 and 200.
30.
Write a program to print the following pattern:
A
BCD
EFGHI
JKLMNOP
QRSTUVWXY
31.
Write a program to check whether a number is prime or composite.
32.
Write a Python program to print the Fibonacci series.
33.
Krrishnav is looking for his dream job but has some restrictions. He loves Delhi and would take a job there, if he is paid over ₹ 40000 a month. He hates Chennai and demands at least ₹ 100000 to work there. In any another location, he is willing to work for ₹ 60000 a month. The following code shows his basic strategy for evaluating a job offer.
pay = ____________
location=___________
if location == "Mumbai":
print ("I'll take it!") #Statement 1
elif location == "Chennai":
if pay < 100000:
print ("No way") #Statement 2
else:
print("I am willing!") #Statement 3
elif location "Delhi" and pay > 40000:
print("I am happy to join") #Statement 4
elif pay > 60000:
print("I accept the offer") #Statement 5
else:
print ("No thanks. I can find something better") #Statement 6
On the basis of the above code, choose the right statement which will be executed when different inputs for pay and location are given.
(i) Input: location = "Chennai", pay = 50000
A Statement 1
B Statement 2
C Statement 3
D Statement 4
(ii) Input: location = "Surat", pay = 50000
A Statement 2
B Statement 4
C Statement 5
D Statement 6
(iii) Input: location = "Any Other City", pay = 1
A Statement 1
B Statement 2
C Statement 4
D Statement 6
(iv) Input: location = "Delhi", pay = 50000
A Statement 6
B Statement 5
C Statement 4
D Statement 3
(v) Input: location = "Lucknow", pay = 65000
A Statement 2
B Statement 3
C Statement 4
D Statement 5
34.
Riya wrote a program to print the Fibonacci series. But some words or lines had missing. Help her to execute the given program.
n = int. (input ("How many terms?))
n1, n2 = 0,1
count = 0
if n <= 0
print ("Please enter a positive number")
elif
print("fibonacci sequence upto", n, ":")
print (____)
else :
print ("Fibonacci sequence:")
while count <n:
print (n1)
n3 = _____________
n1=n2
n2 = _____________
count = count +1
(i) Write the symbol which will terminate the line 4.
(ii) Fill the blank in line 6 to satify the condition.
(iii) Write the variable which print in line 8
(iv) Write the value which will be assign to variable n3.
(v) Fill the blank in line 15.
35.
Data types are the classification of data items in Python. They define the type of value a variable can hold and what operations can be performed on it. Since everything in Python is an object, data types are actually classes, and variables are instances (objects) of these classes.
Python provides the following standard (built-in) data types:
• Numeric Represents numbers. It includes
→ int integers (e.g., 10, -5)
→ float decimal or floating-point numbers (e.g., 3.14, -2.5)
→ complex numbers with real and imaginary parts (e.g., 3 + 4j)
• Sequence Type An ordered collection of items that can be of the same or different data types.
e.g. list, tuple, and string.
• Boolean Holds only Two values - True and False
It represents truth values and is used in logical expressions and decision-making.
• Set An unordered, mutable collection that stores unique elements.
e.g. {1, 2, 3}
• Mapping An unordered collection of key-value pairs.
The standard mapping type in Python is the dictionary (dict).
(i) How many values are there in Boolean data type?
(ii) What do you mean by sequence data type?
(iii) List the types of numeric data type.
(iv) What is the use of None?
(v) Write the output of
>>> type("Arihant").
1.
break statement is used to terminate the execution of the loop.
For example,
for i in range(6):
if 1-3:
break
print (1)
The output of the above code will be:
0
1
2
The loop terminates when i becomes 3 due to break statement.
Whereas, continue statement is used to force the next iteration while skipping the statements in the present iteration.
For example,
for i in range(6):
if i == 3:
continue
print(1)
The output of the above code will be
0
1
2
4
5
2.
x = int(input("Enter a number:"))
if (x>0) :
print ("Positive")
elif (x<0):
print ("Negative")
else :
print ("Zero")
3.
num = int(input ("Enter a number: "))
if num %2==0:
print("The half number is: ", num/2)
else :
print ("The next number is: ", num+1)
print ("Thank You!")
4.
A language is dynamically typed if the type is associated with run-time values and not named variables/fields etc.
This means that you as a programmer can write a little quicker because you do not have to specify types every time.
Python is a dynamically type language. It does not know about the type of the variable until the code is run, so declaration is no use. It stores the value at some memory location and then binds that variable name to that memory container.
We have assigned three values to three variables:
>>> a - 10
>>> name = "Neha"
>>> x = 34.6
But what types are these variables? Let's use the type
( ) module to find out:
Syntax type (variable_name)
5.
(i) 21
(ii) -1
(iii) 6
(iv) False
(v) False
(vi) 68
(vii) 86
(viii) True
6.
(i) A=10 *4//2+4-2// 2 + 4 - 3 +5//8
=40//2+4-2// 2 + 4 - 3 +5//8 operation: *
=20+4-2// 2 + 4 - 3 +5//8 operation: //
= 20 + 4 - 1 + 4 - 3 +5//8 operation: //
= 20 + 4 - 1 + 4 - 3 + 0 operation: //
= 24 - 1 + 4 - 3 + 0 operation : +
=23+4-3 operation : -
=27-3-24 operation : +
(ii) A=5+6//3+10* 3// 4 + 2 +3//4
= 5 + 2 +10* 3//4+2+3//4
= 5 + 2 +30//4+2+3//4 operation : "
= 5 + 2 + 7 + 2 +3//4 operation: //
= 5 + 2 + 7 + 2 + 0 operation : +
= 7 + 7 + 2 = 16
(iii) A=5* 5+4// 5 + 15 -9//2+10
= 25 + 4//5 +15-9//2 + 10 operation : *
= 25 + 0 + 15 -9//12+10 operation: //
= 25 + 0 + 15 - 4 + 10 operation : +
=40-4+10 operation: -
=36+10=46
7.
(i) p / q + a - c valid
(ii) q (a + b + (- z / 4) invalid because operator missing between q and a
(iii) p / q + a - c valid
(iv) x / y + p * a/b valid
(v) a * +b invalid because use of two operators together
(vi) a +b*c* 2 valid
8.
(i) Comments A hash sign (#) that is not inside a string literal begins a single line comment. We can use triple quoted string for giving multi-line comments.
(ii) Variables A variable in Python is defined through assignment. There is no concept of declaring a variable outside of that assignment.
(iii) Data type It is a set of values and the allowable operations on those values. Python has a great set of useful datatypes
9.
Value = 30
for val in range (0, Value) : # Error 1
if val % 4 == 0: # Error 2
print (val*4)
elif val%5 == 0: # Error 3
print (val + 3)
else : # Error 4
print (val + 10)
10.
• range(1, 8) generates numbers from 1 to 7.
• if i % 2 == 0: continue skips even numbers, so only odd numbers are considered for printing.
• if i == 7: break stops the loop when i reaches 7.
• print(i, end="") prints the numbers on the same line.
Output
1 3 5
11.
Output
23
12.
We can use a for loop with a break statement to stop the loop when the number 7 is encountered.
stopping at 7
for i in range(1, 11):
if i == 7:
break # Stop the loop when 7 is encountered
print(i)
Output
1
2
3
4
5
6
13.
for i in range (3, 5):
if (i = = 4) :
print ("Welcome")
else :
print ("No entry")
print ("value of i", i)
14.
Output
m = 4
k = 2
j = 1
15.

16.
The algorithm is
Step 1 Input "Enter a Number" N
Step 2 Let R = N% * 3
Step 3 If R = 0 then "N is divisible by 3"
Step 4 If R! = 0 then "N is not divisible by 3"
Step 5 Stop
17.
(i) (weight >=115 and weight < 125)
(ii) ((Donation>=4000 and Donation<= 5000) or Guest = =1)
18.
Output
a: 175
b: 15
x: 50
y: 25
z: 100
19.
Output is 32
20.
Output
x : 15
y : 3
z : 12
21.
num=7.5
22.
a =15
b=15
c = False
23.
i : 10
j : 15
k : 13.0
l :18.0
m : 2
n : 49.0
24.
The operator will be performed before //. Though both have same priority but in this expression * is prior to //.
A=12//5+5// 7 + 8 - 2+4//2
=2+5// 7 + 8 - 2+4//2
operation: //
= 2 + 0 + 8 - 2 + 4//2
operation: //
= 2 + 0 + 8 - 2 + 2
operation: //
= 2 + 0 + 6 + 2
operation : -
=10
operation : +
25.
(i) Num = 2
(ii) Num = 2
(iii) Num = 10
26.
Differences between identifier and keyword are
Identifier | Keyword |
|---|---|
Identifier consists any combination of letters, numbers and underscores. | Keyword must consist only letters. |
It allows both uppercase and lowercase. | It allows only lowercase except True, False and None. |
e.g. x, sum_5,_mul etc. | e.g. finally, continue, yield etc |
27.
num = int(input("Enter a number: ") )
temp = num
reverse = 0
while temp > 0:
remainder = temp % 10
reverse = (reverse 10) + remainder
temp = temp // 10
if num == reverse:
print ('Palindrome')
else:
print ("Not Palindrome")
28.
n = 5
k=n-1
for i in range(0, n):
for j in range(0, k):
print("", end="")
k-k-1
for j in range(0, i+1):
print("*", end-"")
print ( )
29.
print("The Armstrong numbers in between 1 and 200 are")
for i in range(1, 201, 1):
k = 0
j = i
while (j > 0) :
I =j%10
k = k + I *I*I
j =j//10
if (k = - i) :
print(i)
30.
incr1
val - 65
for i in range(0,5):
for j in range(0, incr):
ch = chr(val)
print(ch, end = "")
val = val + 1
incr = incr + 2
print ( )
31.
num = int(input("enter a number: * ))
flag - False
if num > 1:
for i in range(2, num):
if (num % i) == 0:
flag = True
break
if flag:
print(num, "is not a prime number")
else :
print(num, "is a prime number")
32.
n = int(input("How many terms?"))
# first two terms
n1, n2 = 0, 1
count = 0
# check if the number of terms is valid
if n < = 0:
print ("please enter a positive integer")
elif n ==1:
print ("Fibonacci sequence upto :", n, ":")
print (n1)
else:
print ("Fibonacci sequence:")
while count < n:
print (n1)
nth= n1 + n2
# update values
n1 = n2
n2 = nth
count + = 1
33.
(i) (B) When user enters input as location = Chennai and pay =50000, then location == "Chennai" condition will be true. After that, pay < 100000: will be check it also true, so print ("No way") statement 2 will be execute.
(ii) (D) When location = "Surat, pay =50000 entered by user then statement 6 will be execute.
(iii) (D) When location = "Any Other City", pay =1 entered by user then statement 6 will be execute because it does not satisfied any given condition.
(iv) (C) When location = "Delhi", pay =50000 entered by user then statement 4 will be execute.
(v) (D) When location = "Lucknow", pay =65000 entered by user then statement 5 will be execute.
34.
(i) (colon)
(ii) n==1:
(iii) n1
(iv) n1 + n2
(v) n3
35.
(i) Two values - True and False.
(ii) It is an ordered collection of elements (like list, tuple, or string) that allows storing multiple items in a specific order.
(iii) Integer (int), Floating-point (float), and Complex (complex).
(iv) None represents the absence of a value or a null value in Python. It is often used to initialize variables or indicate "no result."
(v) <class 'str'>
12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Business Studies Planning Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Business Environment Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Principles of Management Important Questions And Answers Study Material - QB365 Set A
NCERT Books
Syllabus
Exam Pattern
Sample Question Papers
Previous year Question Papers
Important Notes
MCQ Practice test
NCERT Exemplers
Case study Questions
Image Based Questions
Passage based Questions
HOT Questions
Value Based Questions
Model Questions Papers
NCERT ( Book Back ) Questions
Assertion and Reason
Important Questions And Answers
CBSE 12th Standard CBSE Subjects
CBSE Standards