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

:

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

:

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

:

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

:

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

:

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

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

:

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

:

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

:

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

:

```for i in range(7,-2,-9):
for j in range(i):
print(j)
```
```Show Answer0
1
2
3
4
5
6
```

:

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

## Python Output based Questions-Test 2

Q2. Write the output of the following code :

:

```for i in range(1,8):
print(i)
i+=2

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

In :

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

:

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

:

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

:

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

:

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

:

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

:

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

:

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

:

```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.

:

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

:

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

:

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

:

```for i in [10,20,30]:
print("Hello",i)
```
```Show AnswerHello 10
Hello 20
Hello 30
```

:

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

:

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

:

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

:

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

:

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

:

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

## Python Output based Questions-Test 4

Q4. Write the output of the following code:

:

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

:

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

:

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

:

```i=0
while(i<5):
for j in range(i):
print(j,end="s")
i=i+1
```
`Show Answer0s0s1s0s1s2s0s1s2s3s`

:

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

:

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

:

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

:

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

:

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

:

```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 :

:

```x=5

while(x<15):
print(x**2)
x+=3
```
```Show Answer25
64
121
196
```

:

```a=7
b=5

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

:

```b=5

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

:

```b=15

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

:

```x=15

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

:

```x = "123"

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

:

```i=9

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

:

```a=5

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

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

:

```i=0

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

:

```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 :

:

```i=2

for x in range(i):
i+=1
print(i)
print(i)
```
```Show Answer3
3
4
4
```

:

```i=2

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

:

```i=2

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

:

```i=100

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



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

```



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

```
```Show AnswerAa
AaAa
AaAaAa
AaAaAaAa

```



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

```
```Show AnswerAS
ASAS
ASASAS
ASASASAS

```



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

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



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

```
```Show Answer2

```



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

```
```Show Answer64

```

## Python Output based Questions-Test 7

Q7. Write the output of the following code :



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



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



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



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



```for i in range(0,2,-1):
`print("Hello")````
`Show AnswerAns. No Output`



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



```s1="csiplearninghub.com"
c=0
for x in s1:
if(x!="l"):
c=c+1
print(c)```
`Show AnswerAns. 18`



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



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



` 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