0% found this document useful (0 votes)
107 views7 pages

Output Based Questions

Uploaded by

Saranyaa D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views7 pages

Output Based Questions

Uploaded by

Saranyaa D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

VELAMMAL VIDHYASHRAM

BHAGAT SINGH WING


GRADE 12 – OUTPUT BASED QUESTIONS
CODE – 083 – COMPUTER SCIENCE

1. Find the output of the following code.


s=”Be Good”
s=s.partition(“g”)
print(“*”.join(s))

2. What will be the output for the following Python statements?


T = (10,20, [30,40,50],60,70)
T [2][1] = 100
print (T)

3. What will be the output for the following Python statements?


L= [10,20,30,40,50]
L=L+5
print(L)

4. What will be the output for the following Python statements?


D= {“AMIT”:90, “RESHMA”:96, “SUKHBIR”:92, “JOHN”:95}
print (“JOHN” in D, 90 in D, sep =”#”)

5. Find the output of the following code.


Suppose the content of a text file Notes.txt is:
“The way to get started is to quit talking and begin doing”
What will be output of the following Python code?
F=open (“Notes.txt”)
F.seek(29)
S=F.read()
print (S)

6. Identity the output of the following Python statements


S=” GOOD MORNING”
print(S.captialize(), S.title(), end=”!”)
7. Identify the output of the following Python statements.
L= [ ]
for i in range (4):
L.append(2*i+1)
print (L[: : -1])

8. Identify the output of the following Python statements:


D={ }
T=(“ZEESHAN”, “NISHANT”,”GURMEET”,”LISA”)
for i in range(1,5):
D[i] = T[i-1]
print(D)

9. Identify the output of the following Python statements.


L1, L2 = [10,15,20,25], [ ]
for i in range (len(L1)):
L2.insert(i,L1.pop())
print (L1, L2, sep=”&”)

10. What will be the output of the following Python code?


S=”WELCOME”
def Change(T):
T=” HELLO”
print(T, end=’@’)
Change(S)
print(S)
11. Identify the correct possible output for the following Python code:
import random
for N in range(2,5,2):
print(random.randrange(1,N), end=”#”)

12. What will be the output of the following Python code?


def FunStr(S):
T=” “
For I in S:
If i.isdigit() :
T=T+i
Return T
X=”PYTHON 3.9”
Y=FunStr(X)
print(X, Y, sep=”*”)

13. What will be the output of the following Python code?


V=50
def Change(N):
global V
V, N = N, V
print(V, N, sep=”#”, end=”@”)
Change(20)
print(V)

14. Which of the following option can be the output for the following Python code?
L1 = [10,20,30,40,50]
L2= [ ]
for i in L1:
if i not in L2:
L2.append(i)
print (L1, L2, sep=”&”)

15. What is the output of the following Python code?


def ListChange() :
for I in range (len(L)):
if L[i]%2 ==0:
L[i] = L[i]*2
If L[i]%3 ==0:
L[i]=L[i]*3
Else:
L[i]=L[i]*5
L= [2,6,9,10]
ListChange()
for i in L:
print(i,end=”#”)

16. Suppose the content of a text file “Rhymes.txt” is as follows:


Jack & Jill
went up the hill
What will be the output of the following Python code?
F=open(“Rhymes.txt”)
L=E=F.readlines()
for i in L:
S=i.split()
print(len(S), end=”#”)

17. What possible output(s) will be obtained when the following code is executed? Also write
the minimum and maximum values of Low and High.
Import random as ran
Low=2+ran.randint(1,3)
High=5+ran.randint(0,3)
C=”ABCDEFGHIJ”
for I in range(Low,High):
print(C[I],end=” “)

18. What will be the output of the following code?


def alter(num):
num+=a
print(a,end=” “)
a=5
num = 10
num=alter(a)
print(num,a)

19. Find the output of the following code


L=[1,2,3,4,5,6]
L[2:4]=”CBSE”
print(L)
print(L[:-1:2])

20. Write the output of the following code


def outer_fun(a,b):
def inner_fun(c,d):
return c+d
return inner_fun(a,b)
return a
result = outer_fun(15,10)
print(result)

21. Suppose the content of “Rhymes.rtxt” is


Good Morning Madam
What will be the output of the following Python code?
F=open(“Rhymes.txt”)
L=F.read(). Split()
For W in L:
If W.Lower() == W[: : -1].lower():
print(W)

22. Suppose the content of “Rhymes.txt” is


Hickory Dickory Dock
The mouse went up the clock
What will be the output of the following Python code?
F=open(“Rhymes.txt”)
L=F.readlines()
X=[“the,”ock”]
for i in L:
for W in i.split():
If W in X:
print(W, end=”*”)

23. What will be the output of the following Python code?


S=”UVW” ; L=[10,20,30] ;D={ }
N=len(S)
for I in range(N):
D[L[I] = S[I]
for K,V in D.itmes():
print (K,V, sep =”*”, end=” “)

24. What will be the output of the following Python code?


L=[10,20]
L1=[30,40]
L2=[50,60]
L.append(L1)
L.extend(L2)
print(L)

25. What possible output(s) will be obtained when the following code is executed?
Import random
myNumber = random.randint(0,3)
COLOR=[“YELLOW”,”WHITE”,”BLACK”,”RED”]
for I in COLOR:
for j in range (1,mynumber):
print(I, end = “ “)
print ()

26. Write the output as well as the number of times the loop runs?
s="cbse"
a=0
for x in s[3:8]:
print(x)
a+=1
print(a)
27. Predict the output of the following code:
def Changer(P,Q=10):
P=P/Q
Q=P%Q
return P
A=200
B=20
A=Changer(A,B)
print(A,B,sep=”$”)
B=Changer(B)
print(A,B,sep=”$”,end=”###”)
28.
29.
30.

You might also like