
Table of Contents
- Python Output based Questions-Test 1
- Python Output based Questions-Test 2
- Python Output based Questions-Test 3
- Python Output based Questions-Test 4
- Python Output based Questions-Test 5
- Python Output based Questions-Test 6
- Python Output based Questions-Test 7
Python Output based Questions-Test 1
Q1. Write the output of the following code:
[1]:
for i in range(5):
print(i)
0 1 2 3 4
[2]:
for i in (1,2,3):
print(i)
1 2 3
[3]:
for i in (2,3,4):
print("i")
i i i
[4]:
for i in (4,3,2,1,0):
print(i, end=" ")
4 3 2 1 0
[5]:
for i in range(10):
if(i%2!=0):
print("Hello",i)
Hello 1 Hello 3 Hello 5 Hello 7 Hello 9
[6]:
for i in range(10,2,-2):
print(i, "Hello")
10 Hello 8 Hello 6 Hello 4 Hello
[7]:
str = "Python Output based Questions"
word=str.split()
for i in word:
print(i)
Python Output based Questions
[8]:
for i in range(7,10):
print("Python Output based Questions")
print("Python Output based Questions")
Python Output based Questions Python Output based Questions Python Output based Questions Python Output based Questions
[9]:
for i in range(7,-2,-9):
for j in range(i):
print(j)
0 1 2 3 4 5 6
[10]:
i="9"
for k in i:
print(k)
9

Python Output based Questions-Test 2
Q2. Write the output of the following code :
[11]:
for i in range(1,8):
print(i)
i+=2
1 2 3 4 5 6 7
In [12]:
for i in range(4,7):
i=i+3
print("Hello")
Hello Hello Hello
[13]:
for i in range(4,7):
i=i+3
print("Hello",i)
Hello 7 Hello 8 Hello 9
[14]:
i=4
while(i<10):
i=i+3
print(i)
7 10
[15]:
for i in range(20):
if i//4==0:
print(i)
0 1 2 3
[16]:
x=1234
while x%10:
x=x//10
print(x)
123 12 1 0
[17]:
for i in 1,2,3:
print(i*i)
1 4 9
[18]:
for i in 2,4,6:
print("H"*i)
HH HHHH HHHHHH
[19]:
p=10 q=20 p=p*q//4 q=p+q**3 print(p,q)
50 8050
[20]:
x=2 y=6 x=x+y/2 + y//4 print(x)
6.0

Python Output based Questions-Test 3
Q3. Write the output of the following.
[21]:
n=11
for i in range(2,n//2):
if n%i!=0:
print("Python Output based Questions")
break
else:
print("Bye")
Python Output based Questions
[22]:
n=20
for i in range(2,n//4):
if n%i==0:
print("Python Output based Questions")
else:
print("Bye")
Python Output based Questions Bye Python Output based Questions
[23]:
for i in 123:
print(i)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-23-f5b16f0d3ced> in <module> ----> 1 for i in 123: 2 print(i) TypeError: 'int' object is not iterable
[24]:
for i in [10,20,30]:
print("Hello",i)
Hello 10 Hello 20 Hello 30
[25]:
x=2
for i in range(x**2,x,-1):
print(x)
2 2
[26]:
x=10
for i in range(x):
if x==5:
break
print("H")
print(x)
10
[27]:
x=6
for i in range(x):
if x==5:
break
print("H")
print(x)
H H H H H H 6
[28]:
s=0
for i in range(5):
s=s+i
print(s)
0 1 3 6 10
[29]:
for i in range(1,11):
print("%d"%i)
1 2 3 4 5 6 7 8 9 10
[30]:
print((3>1) and (9<1))
False

Python Output based Questions-Test 4
Q4. Write the output of the following code:
[31]:
print((9>1) or (9<1))
True
[32]:
f=0
while(f<10):
print(f)
f=f*3
Loop will run infinite
[33]:
for i in range(5):
for j in range(i):
i=i+j
print(i,end="@")
print(j)
1@2@3@3@4@6@4@5@7@10@3
[34]:
i=0
while(i<5):
for j in range(i):
print(j,end="s")
i=i+1
0s0s1s0s1s2s0s1s2s3s
[35]:
num1=7
num2=10
for i in range(5):
num2=num2+10
print(num2)
print(num1)
20 7 30 7 40 7 50 7 60 7
[36]:
s=0
for i in range(-5,5):
s=s+i
print(s)
-5
[37]:
for i in range(5):
if i%2==0:
pass
else:
print(i)
1 3
[38]:
for i in range(5):
if i%2==0:
continue
else:
print(i)
1 3
[39]:
for i in range(1,5):
if i%2==0:
break
else:
print(i)
1
[40]:
for i in range(5):
while(i):
print(i,end=" ")
i=i-1
print()
1 2 1 3 2 1 4 3 2 1

Python Output based Questions-Test 5
Q5. Write the output of the following code :
[41]:
x=5 while(x<15): print(x**2) x+=3
25 64 121 196
[42]:
a=7 b=5 while(a<9): print(a+b) a+=1
12 13
[43]:
b=5
while(b<9):
print("H")
b+=1
H H H H
[44]:
b=15
while(b>9):
print("Hello")
b=b-2
Hello Hello Hello
[45]:
x=15
while(x==15):
print("Hello")
x=x-3
Hello
[46]:
x = "123"
for i in x:
print("a")
a a a
[47]:
i=9
while True:
if i%3==0:
break
print("A")
Loop will not execute
[48]:
a=5
while(a<=10):
print("a")
a+=1
a a a a a a
[49]:
i=0 while i<3: print(i) i=i+1 else: print(7)
0 1 2 7
[50]:
i=0 while i<3: print(i) i=i+1 print(0)
0 0 1 0 2 0

Python Output based Questions-Test 6
Q6. Write the output of the following code :
[51]:
i=2 for x in range(i): i+=1 print(i) print(i)
3 3 4 4
[52]:
i=2 for x in range(i): x+=1 print(x) print(x)
1 2 2
[53]:
i=2
for x in range(i):
x+=1
print(x)
print("x")
1 x 2 x
[54]:
i=100 while i<57: print(i) i+=5
Loop will run infinite times
[55]
for i in range(5):
for j in range(i):
print("A",end=" ")
print()
A A A A A A A A A A
[56]
for i in range(5):
for j in range(i):
print("A",end="a")
print()
Aa AaAa AaAaAa AaAaAaAa
[57]
for i in range(5):
print("AS"*i,"\n")[/showhide]
AS ASAS ASASAS ASASASAS
[58]
for i in range(5):
for j in (i):
print("AS"*i,"\n")
Shows Error
[59]
print(10*2//3**2)
2
[60]
print(12+34-320+23**2)
64

Python Output based Questions-Test 7
Q7. Write the output of the following code :
[61]
a = 7
for i in 7:
print(a)Ans. Shows Error
[62]
a = "AMIT"
for i in range(len(a)):
print(a)Ans. AMIT AMIT AMIT AMIT
[63]
x = "Welcome to my blog"
j = "i"
while j in x:
print(j)Ans. Loop will execute infinite times.
[64]
print(range (5, 0, -2))
Ans. range (5, 0, -2)
[65]
for i in range(0,2,-1):
print("Hello")Ans. No Output
[66]
s1="csiplearninghub.com"
s2=""
s3=""
for x in s1:
if(x=="s" or x=="n" or x=="p"):
s2+=x
print(s2,end=" ")
print(s3)Ans. spnn
[67]
s1="csiplearninghub.com"
c=0
for x in s1:
if(x!="l"):
c=c+1
print(c)Ans. 18
[68]
j=12
c=9
while(j):
if(j>5):
c=c+j-2
j=j-1
else:
break
print(j, c)
print(c)Ans. 5 58 58
[69]
L = [13 , 12 , 21 , 16 , 35 , 7, 4]
s = 5
s1 = 3
for i in L:
if (i % 4 == 0):
s = s + i
continue
if (i % 7 == 0):
s1 = s1 + i
print(s , end=" ")
print(s1)Ans. 37 66
[70]
print('cs' + 'ip' if '234'.isdigit() else 'IT' + '-402')Ans. csip
Class 12 Computer Science Sample Paper 2020-2021.
Class 12 Computer Science Sample Paper Marking Scheme
Class 12 Computer Science Test Series