Python Assessment-100
Python Assessment-100
Total Questions - 50
1)
A) i,ii,iii 1M
B) i,iii,ii
C) iii,ii,i
D) ii,iii,i
3) Which of the following is the correct output on running the below code in Python?
print(“The output is:”)
print(“Hello!”)
C) 5.1>5
D) None of the above
A) 9.1>'9.1' 1M
B) '9'>'9.1'
C) 9!='9'
D) Both a and c
print(2**1*3,end=” “)
print(2*1**3)
A) 2 2 1M
B) 6 2
C) 6 6
D) 2 6
str1=str(1234)
str2=’1234′
print(str1==str2,end=” “)
print(str1 is str2)
A) True True 1M
B) False True
C) False False
D) True False
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 2/19
12/14/23, 4:42 PM Python Assessment-100%
9)
x= 5+(6>4)+6/3*5
print(x)
A) 16.0 1M
B) 8.0
C) 6.0
D) 24.0
a.
a=4
b=5
if(a>b):
print(‘a>b’)
elif(a<b and a==b):
print(‘a<=b’)
b.
a=4
b=5
if(a>b):
print(‘a>b’)
elif:
print(‘a<=b’)
c.
a=4
b=5
if(a>b):
print(‘a>b’)
elif(a<b):
print(‘a<b’)
else: print(‘a==b’)
A) a 1M
B) b
C) c
D) both a and b
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 3/19
12/14/23, 4:42 PM Python Assessment-100%
a.
opt=2
if(opt==1):
print(‘Choosen first option’)
elif(opt==2):
print(“Choosen second option”)
elif(opt==3):
print(‘Choosen third option’)
b.
if(1): print(“If block”)
else: print(“Else block”)
c.
no=5
if(no%2==0):
print(‘Even Number’)
else(no%2==1):
print(‘Odd Number’)
A) a 1M
B) c
C) b and c
D) b
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 4/19
12/14/23, 4:42 PM Python Assessment-100%
a.
a=10
b=4
if(a&b):
print((a-b)/2)
else:
print(a-b/2)
b.
a=10
b=4
if(a^b):
print((a-b)/2)
else:
print(a-b/2)
c.
a=10
b=4
if(~a):
print(a-2*b+1)
else:
print(a-b/2)
d.
a=10
b=4
if(a-b):
print(a-2*(b+1))
else:
print(a-b/2)
A) a 1M
B) b
C) c
D) d
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 5/19
12/14/23, 4:42 PM Python Assessment-100%
a.
a=4
b=5
if(a>b):
print(‘a>b’)
elif(a<b and a==b):
print(‘a<=b’)
b.
a=4
b=5
if(a>b):
print(‘a>b’)
elif:
print(‘a<=b’)
c.
a=4
b=5
if(a>b):
print(‘a>b’)
elif(a<b):
print(‘a<b’)
else: print(‘a==b’)
A) a 1M
B) b
C) c
D) both a and b
for i in range(1,6,2):
if (i==4):
break
print(i,end=” “)
A) 1 3 1M
B) 1 2 3
C) 2 6
D) 1 3 5
15) Which of the following functions cannot be used to add an element to the list?
A) add() 1M
B) insert()
C) append()
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 6/19
12/14/23, 4:42 PM Python Assessment-100%
D) extend()
set1={‘a’,’o’,’e’,’u’,’i’}
enm=enumerate(set1)
enm=enumerate(set1)
print(set(enm))
Ans 3
A) {‘a’,’e’,’i’,’o’,’u’} 1M
B) {{0, 'i'}, {2, 'a'}, {1, 'u'}, {3, 'o'}, {4, 'e'}}
C) {(0, 'i'), (2, 'a'), (1, 'u'), (3, 'o'), (4, 'e')}
D) <enumerate object at 0x0000018C2A10D280>
set1={3.5,’g’,6,3}
set2={‘h’,4,3,’y’}
set1.symmetric_difference(set2)
20) Which of the following gives the out put as 3 if the dictionary is
dic={‘a’:{3:4,6:2},’t’:5,7:{1:3,9:1}}
A) dic[‘a’][1] 1M
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 7/19
12/14/23, 4:42 PM Python Assessment-100%
B) dic[7][1]
C) dic[0][1]
D) dic[7][0]
A) 2 1M
B) 3
C) 4
D) 1
File: main.py
Code
>>> import greet
>>> greet.say_hello(“William”)
A) Hello William. 1M
B) Hello {name}.
C) SyntaxError
D) Program compiles but doesn’t print anything
24)
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 8/19
12/14/23, 4:42 PM Python Assessment-100%
minions.py
Code
>>> def fav_food():
>>> print(“Bananas”)
>>> if __name__ == “__main__”:
>>> fav_food()
File: run_minions.py
Code
>>> import minions
>>> minions.fav_food()
25)
File: Cars.py
Code
>>> def car():
>>> print(‘A car’)
File: main.py
Code
>>> from Cars import car
>>> def car():
>>> print(“Not a car”)
>>> car()
A) Not a car 1M
B) a car
C) Runtime Error
D) Compile-time Error
def fun(x,y=0,z):
print(x-y+z)
fun(1,23)
A) 24 1M
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 9/19
12/14/23, 4:42 PM Python Assessment-100%
B) -22
C) 23
D) SyntaxError
27)
A) class 1M
B) __main__
C) AttributeError
D) Fruit
A) remove 1M
B) delete
C) pop
D) del
A) 0 1M
B) 1
C) 2
D) More than two
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 10/19
12/14/23, 4:42 PM Python Assessment-100%
>>> a = Multiply(5)
>>> b = Multiply(10)
>>> print(a * b)
A) 50 1M
B) 5 X 10 = 50
C) a X b = a * b
D) Both A and B
A) SyntaxError 1M
B) 5
C) 4
D) 3
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 11/19
12/14/23, 4:42 PM Python Assessment-100%
33)
.class SomeClass:
>>> def __init__(self):
>>> self.attr1 = “Hello World”
>>> obj = SomeClass()
>>> setattr(obj, ‘attr2′, getattr(obj,’attr1’))
>>> print(obj.attr2)
A) getattr(obj,'attr1') 1M
B) Hello
C) AttributeError
D) Hello World
>>> a1 = Apple(100)
>>> a2 = Apple(25)
>>> a3 = Apple(a1.apples % (Apple(10).apples + a2.apples))
>>> print(a3.apples)
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 12/19
12/14/23, 4:42 PM Python Assessment-100%
A) 28 1M
B) 25
C) 30
D) 35
A) Priyanka – B Positive 1M
B) Reeta – B Positive
C) Runtime error
D) Compile-time error
n=0
assert n>0
raise
except:
print(“Exception”)
A) AssertionError 1M
B) AssertionErrorException
C) Exception
D) None of the above
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 13/19
12/14/23, 4:42 PM Python Assessment-100%
>>> @abstractmethod
>>> pass
>>> ac = AbstractClass()
>>> print(ac)
A) TypeError 0M
B) ac
C) AbstractClass
D) object
Code
>>> class Sum:
>>> def __init__(self, n):
>>> self.n = n
>>> num = 0
>>> if isinstance(int, object):
>>> num += 1
>>> if isinstance(num, object):
>>> num += 4
>>> if isinstance(Sum, object):
>>> num += 6
>>> N = Sum(num)
>>> if isinstance(N, (object, Sum)):
>>> num += 2
>>> print(N.n + num)
A) 20 1M
B) 24
C) 26
D) 14
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 14/19
12/14/23, 4:42 PM Python Assessment-100%
>>> s1 = Square(Square(Square(2).side).area)
>>> print(s1.area)
A) syntaxError 1M
B) TypeError
C) 32
D) 16
A) 11 1M
B) Nord
C) Nord0
D) Nord2
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 15/19
12/14/23, 4:42 PM Python Assessment-100%
Code
>>> class SuperClass:
>>> __hello = “Hello”
A) Hello 1M
B) NameError
C) AttributeError
D) None of the above
Code
>>> class Audio:
>>> def use(self):
>>> print(“To listen”)
A) To listen 1M
B) To see
C) Both A and B
D) AttributeError
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 16/19
12/14/23, 4:42 PM Python Assessment-100%
Code
>>> class Basket:
>>> fruits = 0
>>> @classmethod
>>> def add_fruit(cls):
>>> cls.fruits += 1
>>> basket1 = Basket()
>>> basket1.add_fruit()
>>> basket1.add_fruit()
>>> basket2 = Basket()
>>> print(basket2.fruits)
A) 2 1M
B) 1
C) Error
D) 3
A) 13 1M
B) -7
C) 7
D) -13
D) '''
A) 2 10 x 1M
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 18/19
12/14/23, 4:42 PM Python Assessment-100%
B) 3 c y
C) 1 10 y
D) 2 c x
https://wingz.itvedant.com/index.php/assignment-test-student/exam-view-topic?id=8775 19/19