0% found this document useful (0 votes)
6 views

Share 60 output based questions

The document contains a series of output-based questions related to Python programming, covering various topics such as string manipulation, loops, functions, and data structures. Each question presents a code snippet and multiple-choice answers for the expected output. The questions are designed for Grade 12 Computer Science students at Velammal Vidhyashram.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Share 60 output based questions

The document contains a series of output-based questions related to Python programming, covering various topics such as string manipulation, loops, functions, and data structures. Each question presents a code snippet and multiple-choice answers for the expected output. The questions are designed for Grade 12 Computer Science students at Velammal Vidhyashram.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

VELAMMAL VIDHYASHRAM

BHAGAT SINGH WING


GRADE : 12
SUB: COMPUTER SCIENCE OUPUT BASED QUESTIONS

Q1. Select the correct output of the following python code:


str="My program is program for you"
t = str.partition("program")
print(t)
a) ('My ', 'program', ' is ', 'program', ' for you') b) ('My ', 'program', ' is program for you')
c) ('My ', ' is program for you') d) ('My ', ' is ', ' for you')

Q2. Select the correct output of the code:


for i in "QUITE":
print([i.lower()], end= "#")
(a) q#u#i#t#e# (b) [‘quite#’] (c) ['q']#['u']#['i']#['t']#['e']# (d) [‘quite’] #

Q3. Write the output:-


myTuple = ("John", "Peter", "Vicky")
x = "#".join(myTuple)
print(x)
(a) #John#Peter#Vicky (b) John#Peter#Vicky (c) John#Peter#Vicky# (d) #John#Peter#Vicky#

Q4. What is the output of the following? x = ['ab', 'cd']


for i in x: i.upper()
print(x)
a) [‘ab’, ‘cd’].b) [‘AB’, ‘CD’]. c. [None, None]. D.none of the mentioned

Q5. What is the output of the following? x = ['ab', 'cd']


for i in x: i.upper()
print(x)
a) [‘ab’, ‘cd’].b) [‘AB’, ‘CD’]. C.[None, None]. D.none of the mentioned

Q6. What is the output of the following? i = 1


while True:
if i%3 == 0: break
print(i)
i+=1
a) 1 2 b) 1 2 3 c.error d. none of the mentioned

Q7. Find output generated by the following code:


p=10
q=20
p*=q//3
q+=p=q**2
print(p, q)

Q8. Find output generated by the following code:


Str=”Computer”
Str=Str[-4:]
print(Str*2)

Q9. Find out the output of the Following –


x=20
x=x+5
x=x-10
print (x)
x, y=x-1,50
print (x, y)
Q10. Find out the output of the Following –
for a in range(3,10,3):
for b in range(1,a,2):
print(b, end=’ ‘)
print( )

Q11. FIND OUTPUT OF FOLLOWING


x=10
y=5
for i in range(x-y*2):
print("%",i)

Q12. Find output generated by the following code:


x="one"
y="two"
c=0
while c<len(x):
print(x[c],y[c])
c=c+1

Q13. Find output generated by the following code:


for i in range(-1,7,2): for
j in range(3):
print(i,j)

Q14. Find output generated by the following code:

x="hello world"
print(x[:2],x[:-2],x[-
2:]) print(x[6],x[2:4])
print(x[2:-3],x[-4:-2])

Q15. Find and write the output of the following python code :
def Changer(P,Q=10):
P=P/Q Q=P%Q
print (P,"#",Q)
return P
A=200
B=20
A=Changer(A,B)
print (A,"$",B)
B=Changer(B)
print (A,"$",B)
A=Changer(A)
print (A,"$",B)

Q16. Find and write the output of the following python code:
Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times= Times + C
Alpha= Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)

Q17. Find output generated by the following code:

line = "I'll come by then."


eline = ""
for i in line:
eline += chr(ord(i)+3)
print(eline)

Q18. Find output generated by the following code:

line = "What will have so will" L


= line.split('a')
for i in L:
print(i, end=' ')

Q19. Find output generated by the following code:


p=5/2
q=p*4
r=p+q
p+=p+q+r q-
=p+q*r
print(p,q,r)

Q20. Find the output of the following


L1 = [100,900,300,400,500]
START = 1
SUM = 0
for C in range(START,4):
SUM = SUM + L1[C]
print(C, ":", SUM)
SUM = SUM + L1[0]*10
print(SUM)

Q21. Find the output of the give program :


x = "abcdef" i
= "a" while i
in x:
print(i, end = " ")

Q22. t1=("sun","mon","tue","wed")
print(t1[-1])

Q23. t2=("sun","mon","tue","wed","thru","fri") for i


in range (-6,2):
print(t2[i])

Q24. t3=("sun","mon","tue","wed","thru","fri") if
"sun" in t3:
for i in range (0,3):
print(t2[i])
else:
for i in range (3,6):
print(t2[i])
Q25. t6=('a','b')
t7=('p','q')
t8=t6+t7
print(t8*2)

Q26. t9=('a','b')
t10=('p','q') t11=t9+t10
print(len(t11*2))

Q27. t12=('a','e','i','o','u')
p, q, r, s, t=t12
print("p= ",p)
print("s= ",s)
print("s + p", s + p)

Q28. t13=(10,20,30,40,50,60,70,80)
t14=(90,100,110,120)
t15=t13+t14
print(t15[0:12:3])

Q29. Give the output of the following code:-


list=['p','r','o','b','l','e','m']
list[1:3]=[]
print(list)
list[2:5]=[]
print(list)

Q30. Give the output of the following code:-


l1=[13,18,11,16,13,18,13]
print(l1.index(18))
print(l1.count(18))
l1.append(l1.count(13))
print(l1)

Q31. Find the error in following code. State the reason of the error.
aLst = { ‘a’:1 ,’ b’:2, ‘c’:3 }
print (aLst[‘a’,’b’])

Q32. What is the output of the following:?

list1 = [1, 2, 3, 4, 5]
list2[0] =0;
print("list1= : ", list1)

Q33. What will be the output?

1. d1 ={"john":40, "peter":45}
2. d2 ={"john":466, "peter":45}
3. d1 > d2

Q34. What will be the error of the following code Snippet and give output?
Lst =[1,2,3,4,5,6,7,8,9]
Lst[::2]=10,20,30,40,50,60
Print[Lst]

Q35. Find the error in following code and give output


aLst={‘a’:1,’b’:2,’c’:3}
print(aLst[‘a’,’b’])

Q36. What will be the output of the following Code Snippet?


a =[1,2,3,4,5]
print(a[3:0:-1])
A. Syntax error B. [4, 3, 2]

C. [4, 3] D. [4, 3, 2, 1]

Q37. What will be the output of the following Code Snippet?


a = {(1,2):1,(2,3):2}
print(a[1,2])
A. Key Error B. 1 C. {(2,3):2} D. {(1,2):1}

Q38. What will be the output of the following Code Snippet?


my_dict = {}
my_dict[1] = 1
my_dict['1'] = 2
my_dict[1.0] = 4
sum = 0
for k in my_dict: sum
+= my_dict[k]
print (sum)

Q39. Find the error in following code and give output

Def Sum(a=1,b)
return a+b
print (“The sum =” Sum(7, -1)

Q40. Find the error in following code and give output


def main ( )
print ("hello")
Q41. Find the output of the following numbers:
Num = 20
Sum = 0
for I in range (10, Num, 3):
Sum+=i
if i%2==0:
print (i*2)
else:
print (i*3)

Q42. Find the output of the following-


def power (b , p):
r = b ** P
return r

def calcSquare(a):
a = power (a, 2)
return a

n=5
result = calcSquare(n)
print (result)

Q43. Find the output of the following-


import math
print (math. floor(5.5))

Q44. Find the output of the following-


count =1
def dothis():
global count
for I in (1,2,3):
count+=1
dothis( )
print (count)
Q45. Find the output of the following-
def addem(x,y,z):
print(x+y+z)
def prod(x,y,z):
return x*y*z
A=addem(6,16,26)
B=prod(2,3,6)
print(a,b)
Q46. def Func(message,num=1):
print(message*num)
Func(‘python’)
Func(‘easy’,3)

Q47. def Check(n1=1,n2=2):


n1=n1+n2
n2+=1
print(n1,n2)
Check( )
Check(2,1)
Check(3)

Q48. a=10
def call( ):
global a
a=15
b=20
print(a)
call( )

Q49. Suppose a tuple T1 is declared as T1 = (100,


200, 300, 400, 500)
which of the following is incorrect?
a) print(T[1]) b) T[2] = -29 c) print(max(T)) d) print(len(T))

Q50. What is the output when following code is executed?

>>>A="Best Wishes For CBSE Exam 2021"

>>>A[5:15:2]

Q51. What will be the output of following code-


a={1:"A",2:"B",3:"C"}
for i in a:
print(i,end=" ")
Q52. What will be the output of the following code?
A=(‘AA’,’BB’,’CC’,’AZ’)
print(max(A))
a. AA b. BB c. d.AZ

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


def add (num1=10, num2=23):
sum = num1 + num2
return sum
print(add(20),add(10,20)
a. 43 30 b. 20 23 c.10 20 d. 30 23

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


t1=[12,34,(45,67,[56]),78]
t1[2][2][0]=34
print(t1[2][2][0])

Q55. Following set of commands are executed in shell, what


will be the output?
>>>str="hello"
>>>str[:2]
>>>
a. he b. lo c. olleh d. hello

Q56. What is the output when following code is executed ?


>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]

Q57. What is the output of the following?


print("xyyzxyzxzxyy".count('yy'))

Q58. What is the output when following code is executed ?


>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])

Q59. What is the output when following code is executed ?


names1 = ['Amir', 'Bear', 'Charlton', 'Daman'] n
ames2 = names1
names3 = names1[:]
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print sum

Q60. What will be the output?


d = {"john":40, "peter":45}
print( d["john"])

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy