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)
[2]:
for i in (1,2,3): print(i)
[3]:
for i in (2,3,4): print("i")
[4]:
for i in (4,3,2,1,0): print(i, end=" ")
[5]:
for i in range(10): if(i%2!=0): print("Hello",i)
[6]:
for i in range(10,2,-2): print(i, "Hello")
[7]:
str = "Python Output based Questions" word=str.split() for i in word: print(i)
[8]:
for i in range(7,10): print("Python Output based Questions") print("Python Output based Questions")
[9]:
for i in range(7,-2,-9): for j in range(i): print(j)
[10]:
i="9" for k in i: print(k)
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
In [12]:
for i in range(4,7): i=i+3 print("Hello")
[13]:
for i in range(4,7): i=i+3 print("Hello",i)
[14]:
i=4 while(i<10): i=i+3 print(i)
[15]:
for i in range(20): if i//4==0: print(i)
[16]:
x=1234 while x%10: x=x//10 print(x)
[17]:
for i in 1,2,3: print(i*i)
[18]:
for i in 2,4,6: print("H"*i)
[19]:
p=10 q=20 p=p*q//4 q=p+q**3 print(p,q)
[20]:
x=2 y=6 x=x+y/2 + y//4 print(x)
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")
[22]:
n=20 for i in range(2,n//4): if n%i==0: print("Python Output based Questions") else: print("Bye")
[23]:
for i in 123: print(i)
[24]:
for i in [10,20,30]: print("Hello",i)
[25]:
x=2 for i in range(x**2,x,-1): print(x)
[26]:
x=10 for i in range(x): if x==5: break print("H") print(x)
[27]:
x=6 for i in range(x): if x==5: break print("H") print(x)
[28]:
s=0 for i in range(5): s=s+i print(s)
[29]:
for i in range(1,11): print("%d"%i)
[30]:
print((3>1) and (9<1))
Python Output based Questions-Test 4
Q4. Write the output of the following code:
[31]:
print((9>1) or (9<1))
[32]:
f=0 while(f<10): print(f) f=f*3
[33]:
for i in range(5): for j in range(i): i=i+j print(i,end="@") print(j)
[34]:
i=0 while(i<5): for j in range(i): print(j,end="s") i=i+1
[35]:
num1=7 num2=10 for i in range(5): num2=num2+10 print(num2) print(num1)
[36]:
s=0 for i in range(-5,5): s=s+i print(s)
[37]:
for i in range(5): if i%2==0: pass else: print(i)
[38]:
for i in range(5): if i%2==0: continue else: print(i)
[39]:
for i in range(1,5): if i%2==0: break else: print(i)
[40]:
for i in range(5): while(i): print(i,end=" ") i=i-1 print()
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
[42]:
a=7 b=5 while(a<9): print(a+b) a+=1
[43]:
b=5 while(b<9): print("H") b+=1
[44]:
b=15 while(b>9): print("Hello") b=b-2
[45]:
x=15 while(x==15): print("Hello") x=x-3
[46]:
x = "123" for i in x: print("a")
[47]:
i=9 while True: if i%3==0: break print("A")
[48]:
a=5 while(a<=10): print("a") a+=1
[49]:
i=0 while i<3: print(i) i=i+1 else: print(7)
[50]:
i=0 while i<3: print(i) i=i+1 print(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)
[52]:
i=2 for x in range(i): x+=1 print(x) print(x)
[53]:
i=2 for x in range(i): x+=1 print(x) print("x")
[54]:
i=100 while i<57: print(i) i+=5
[55]
for i in range(5): for j in range(i): print("A",end=" ") print()
[56]
for i in range(5): for j in range(i): print("A",end="a") print()
[57]
for i in range(5): print("AS"*i,"\n")[/showhide]
[58]
for i in range(5): for j in (i): print("AS"*i,"\n")
[59]
print(10*2//3**2)
[60]
print(12+34-320+23**2)
Python Output based Questions-Test 7
Q7. Write the output of the following code :
[61]
a = 7 for i in 7: print(a)
[62]
a = "AMIT" for i in range(len(a)): print(a)
[63]
x = "Welcome to my blog" j = "i" while j in x: print(j)
[64]
print(range (5, 0, -2))
[65]
for i in range(0,2,-1):
print("Hello")
[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)
[67]
s1="csiplearninghub.com" c=0 for x in s1: if(x!="l"): c=c+1 print(c)
[68]
j=12 c=9 while(j): if(j>5): c=c+j-2 j=j-1 else: break print(j, c) print(c)
[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)
[70]
print('cs' + 'ip' if '234'.isdigit() else 'IT' + '-402')
Class 12 Computer Science Sample Paper 2020-2021.
Class 12 Computer Science Sample Paper Marking Scheme
Class 12 Computer Science Test Series