0% found this document useful (0 votes)
44 views8 pages

PYTHON

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)
44 views8 pages

PYTHON

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

PYTHON

1. Identify the output of the following pseudocode.


Var = (2+5/(8+(4*-2)))
If var !=2 then
Display ( “Print var is less than one”)
Else then
Display(“Print var is not less than one”)

a) Var is less than one


b) Var is not less than one
c) Garbage value is printed
d) Error

2. Identify the output of the expression given below whose values are : A = 9, B =
11, C = 10, D =1, where the precedence of the operators from highest to lowest
is +,*, -,/ and all the operators are left associative. B*C+D-B-A*C/D

a) 20
b) 90
c) 110
d) 100

3. Identify the correct statement.


a) List is mutable & Tuple is immutable
b) List is immutable & Tuple is mutable
c) Both are mutable
d) Both are immutable

4. What is the data type of print(type(12))?


a) int
b) float
c) integer
d) number
5. Identify the function that gives the total length of the list?

a. cmp(list)
b. len(list)
c. max(list)
d. length[list]

6. Identify the statement used to create an empty set.


a. {}
b. set 0
c. O
d. set{ }

7. In Python , “String” Datatype

a) Holds alphanumeric data as text


b) Cannot hold whole numbers in text
c) Holds only characters in text
d) Holds Boolean value as text

8. A = True, B = False. Choose the correct option for the following expression:
k=(A or(not B) and (A and B))

a. True
b. False

9. Identify the statement which does not result in error

Sample= {1:”one”,2:”two”,3:”three”}
i. Sample.update({2:”Twenty”,4:”four”})
ii. Print(sample[“four”])
iii. Sample.get(1)
iv. Print(len(sample))

a) i, ii, iii
b) i, iii, iv
c) ii, iii, iv
d) i, ii, iii,iv

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


x = [‘ab’, ‘cd’]
for i in x:
i.upper()
print (x)

a. [‘ab’, ‘cd’]
b. [‘AB’, ‘CD’]
c. [None, None]
d. ERROR MESSAGE

11.Choose the option which results in the following output


message = “Hello, Good Morning. Welcome to python programming Day 4”
output = Good Day

a) print(message[7:11]+“ “+message[-5:-2])
b) print(message[5:9]+“ “+message[-5:2])
c) print(message[6:10]+“ “+message[50:])
d) print(message[-46:-50]+“ “+message[50:54])

12.Predict the output for 22%3.

a. 7
b. 0
c. 1
d. 7.33
13.for i in 10,21,30,40:
if(i%5 ==0):
print(i/2,end = "")
else:
print(i/3,end = "")

C) 5.0 7.0 15.0 20.0

14.k={1,2,2,3,3,3,3,4,5}

for i in k:
print(i-1,end = "")
print(len(k),end = "")
answer : d) 012345

15.what will be the output for the following ?


i=1
While True:
if i%7 ==0:
Break
Print(i)
i+=1

a) 1,2,3,4,5,6
b) 1,2,3,4,5,6,7
c) 0,1,2,3,4,5,6
d) 0,1,2,3,4,5,6,7

16. What will be the output


d= {“john”:40, “peter”:45}
d[“john”]

a) 40
b) 45
c) “john”
d) “Peter”

17. What is the output for


X= [11,13,15,17,19,21]
print(x[::2])

a) [19,21]
b) [11,15]
c) [11,15,19]
d) [13,17,21]

18. Find the values of X and Y using the following values


num1 = -10
num2= 4
n1 = True
n2 = False

X = num1/num2 - num2-(0- num1)


Y = (n1 or (n2 and (not n1))) and n1
a. X = 12.5 , Y = False
b. X = -16.5, Y = True
c. X = -3.5, Y = True
d. x = -3.5, Y = True X = 3.5, Y = False

19.for i in 1,2,3,4,5,6:
do
if ix2 != @ then
display (i, end =)
else then
display(i-1, end = " ")
end - for
Identify the output of the pseudo code
a. 0 224466
b. 0224 46
c. 113355
d. 011335

20.What is the output of the following code


x = 50
def fun1():
x = 25
print(x)
fun1(:
print(x)
a. 25 25
b. 50 50
c. 25 50
21.Identify the function call which does not result in error.
def fun(var1, var2):
print("yes")
i) fun(2,3)
ii) fun(var2=5,3)
iii)fun(var2=5,var1=2)

a. iii
b. Both i and iii
c. i, ii, ii
d. ii

22.count = 10
num=5
sum=0
while (count >5 ):
sum+=count*(num-1)
Print(sum)

a) Infinite loop
b) 60
c) 55
d) 62

You might also like