# 70+ Important (Solved) Python Output based Questions class 11

Share with others

## Python Output based Questions-Test 1

### Q1. Write the output of the following code:

[1]:

```for i in range(5):
print(i)
```
```Show Answer0
1
2
3
4
```

[2]:

```for i in (1,2,3):
print(i)
```
```Show Answer1
2
3
```

[3]:

```for i in (2,3,4):
print("i")
```
```Show Answeri
i
i
```

[4]:

```for i in (4,3,2,1,0):
print(i, end=" ")
```
`Show Answer4 3 2 1 0 `

[5]:

```for i in range(10):
if(i%2!=0):
print("Hello",i)

```
```Show AnswerHello 1
Hello 3
Hello 5
Hello 7
Hello 9
```

[6]:

```for i in range(10,2,-2):
print(i, "Hello")
```
```Show Answer10 Hello
8 Hello
6 Hello
4 Hello
```

[7]:

```str = "Python Output based Questions"
word=str.split()
for i in word:
print(i)
```
```Show AnswerPython
Output
based
Questions
```

[8]:

```for i in range(7,10):
print("Python Output based Questions")
print("Python Output based Questions")
```
```Show AnswerPython 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)
```
```Show Answer0
1
2
3
4
5
6
```

[10]:

```i="9"
for k in i:
print(k)
```
```Show Answer9
```

## 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

```
```Show Answer1
2
3
4
5
6
7
```

In [12]:

```for i in range(4,7):
i=i+3
print("Hello")
```
```Show AnswerHello
Hello
Hello
```

[13]:

```for i in range(4,7):
i=i+3
print("Hello",i)
```
```Show AnswerHello 7
Hello 8
Hello 9
```

[14]:

```i=4
while(i<10):
i=i+3
print(i)
```
```Show Answer7
10
```

[15]:

```for i in range(20):
if i//4==0:
print(i)
```
```Show Answer0
1
2
3
```

[16]:

```x=1234
while x%10:
x=x//10
print(x)
```
```Show Answer123
12
1
0
```

[17]:

```for i in 1,2,3:
print(i*i)
```
```Show Answer1
4
9
```

[18]:

```for i in 2,4,6:
print("H"*i)
```
```Show AnswerHH
HHHH
HHHHHH
```

[19]:

```p=10
q=20
p=p*q//4
q=p+q**3
print(p,q)
```
```Show Answer50 8050
```

[20]:

```x=2
y=6
x=x+y/2 + y//4
print(x)
```
```Show Answer6.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")
```
```Show AnswerPython 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")
```
```Show AnswerPython Output based Questions
Bye
Python Output based Questions
```

[23]:

```for i in 123:
print(i)
```
```Show Answer---------------------------------------------------------------------------
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)
```
```Show AnswerHello 10
Hello 20
Hello 30
```

[25]:

```x=2
for i in range(x**2,x,-1):
print(x)
```
```Show Answer2
2
```

[26]:

```x=10
for i in range(x):
if x==5:
break
print("H")
print(x)
```
```Show Answer10
```

[27]:

```x=6
for i in range(x):
if x==5:
break
print("H")
print(x)
```
```Show AnswerH
H
H
H
H
H
6
```

[28]:

```s=0
for i in range(5):
s=s+i
print(s)
```
```Show Answer0
1
3
6
10
```

[29]:

```for i in range(1,11):
print("%d"%i)
```
```Show Answer1
2
3
4
5
6
7
8
9
10
```

[30]:

```print((3>1) and (9<1))
```
```Show AnswerFalse
```

## Python Output based Questions-Test 4

Q4. Write the output of the following code:

[31]:

```print((9>1) or (9<1))
```
```Show AnswerTrue
```

[32]:

```f=0
while(f<10):
print(f)
f=f*3
```
`Show AnswerLoop will run infinite`

[33]:

```for i in range(5):
for j in range(i):
i=i+j
print(i,end="@")
print(j)
```
```Show Answer1@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
```
`Show Answer0s0s1s0s1s2s0s1s2s3s`

[35]:

```num1=7
num2=10
for i in range(5):
num2=num2+10
print(num2)
print(num1)
```
```Show Answer20
7
30
7
40
7
50
7
60
7
```

[36]:

```s=0
for i in range(-5,5):
s=s+i
print(s)
```
```Show Answer-5
```

[37]:

```for i in range(5):
if i%2==0:
pass
else:
print(i)
```
```Show Answer1
3
```

[38]:

```for i in range(5):
if i%2==0:
continue
else:
print(i)
```
```Show Answer1
3
```

[39]:

```for i in range(1,5):
if i%2==0:
break
else:
print(i)
```
```Show Answer1
```

[40]:

```for i in range(5):
while(i):
print(i,end=" ")
i=i-1
print()
```
```Show Answer1
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
```
```Show Answer25
64
121
196
```

[42]:

```a=7
b=5

while(a<9):
print(a+b)
a+=1
```
```Show Answer12
13
```

[43]:

```b=5

while(b<9):
print("H")
b+=1
```
```Show AnswerH
H
H
H
```

[44]:

```b=15

while(b>9):
print("Hello")
b=b-2
```
```Show AnswerHello
Hello
Hello
```

[45]:

```x=15

while(x==15):
print("Hello")
x=x-3
```
```Show AnswerHello
```

[46]:

```x = "123"

for i in x:
print("a")
```
```Show Answera
a
a
```

[47]:

```i=9

while True:
if i%3==0:
break
print("A")
```
`Show AnswerLoop will not execute`

[48]:

```a=5

while(a<=10):
print("a")
a+=1

```
```Show Answera
a
a
a
a
a
```

[49]:

```i=0

while i<3:
print(i)
i=i+1
else:
print(7)
```
```Show Answer0
1
2
7
```

[50]:

```i=0

while i<3:
print(i)
i=i+1
print(0)
```
```Show Answer0
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)
```
```Show Answer3
3
4
4
```

[52]:

```i=2

for x in range(i):
x+=1
print(x)
print(x)
```
```Show Answer1
2
2
```

[53]:

```i=2

for x in range(i):
x+=1
print(x)
print("x")
```
```Show Answer1
x
2
x
```

[54]:

```i=100

while i<57:
print(i)
i+=5
```
`Show AnswerLoop will run infinite times`

[55]

```for i in range(5):
for j in range(i):
print("A",end=" ")
print()

```
```Show AnswerA
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()

```
```Show AnswerAa
AaAa
AaAaAa
AaAaAaAa

```

[57]

```for i in range(5):
print("AS"*i,"\n")[/showhide]

```
```Show AnswerAS
ASAS
ASASAS
ASASASAS

```

[58]

```for i in range(5):
for j in (i):
print("AS"*i,"\n")

```
```Show AnswerShows Error
```

[59]

```print(10*2//3**2)

```
```Show Answer2

```

[60]

```print(12+34-320+23**2)

```
```Show Answer64

```

## Python Output based Questions-Test 7

Q7. Write the output of the following code :

[61]

```a = 7
for i in 7:
print(a)```
`Show AnswerAns. Shows Error`

[62]

```a = "AMIT"
for i in range(len(a)):
print(a)```
```Show AnswerAns.
AMIT
AMIT
AMIT
AMIT```

[63]

```x = "Welcome to my blog"
j = "i"
while j in x:
print(j)```
`Show AnswerAns. Loop will execute infinite times.`

[64]

`print(range (5, 0, -2))`
`Show AnswerAns. range (5, 0, -2)`

[65]

```for i in range(0,2,-1):
`print("Hello")````
`Show AnswerAns. 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)```
`Show AnswerAns. spnn`

[67]

```s1="csiplearninghub.com"
c=0
for x in s1:
if(x!="l"):
c=c+1
print(c)```
`Show AnswerAns. 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)```
```Show AnswerAns.
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)```
`Show AnswerAns. 37 66`

[70]

` print('cs' + 'ip' if '234'.isdigit() else 'IT' + '-402')`
`Show AnswerAns. csip`

Class 12 Computer Science Sample Paper 2020-2021.

Class 12 Computer Science Sample Paper Marking Scheme

Class 12 Computer Science Test Series

Share with others
error: Content is protected !!