Visit our website
Download KG App
SANCHIT SIR YASH SIR
PROGRAMMING DAILY PRACTICE PAPER 15
1.Find the output :
s1={3, 4}
s2={1, 2}
s3=set()
i=0
j=0
for i in s1:
for j in s2:
s3.add((i,j))
i+=1
j+=1
print(s3)
a.{(3, 4), (1, 2)}
b. Error
c. {(4, 2), (3, 1), (4, 1), (5, 2)}
d. {(3, 1), (4, 2)}
[tcs 2019]
2.Find the output :
class A():
def disp(self):
print("A disp()")
class B(A):
pass
Learn all about Python Programming
University Exam Preparation Course
VINAY SIR SANCHIT SIR
obj = B()
obj.disp()
a. Invalid syntax for inheritance
b. Error because when object is created, argument must be passed
c. Nothing is printed
d. A disp()
[Accenture 2019]
3.Find the output :
count = 1
def doThis():
global count
for i in (1, 2, 3):
count += 1
doThis()
print (count)
a. 4
b. 3
c. 2
d. 0
[Wipro 2019]
4. Find the output :
class student:
def __init__(self):
self.marks = 97
self.__cgpa = 8.7
def display(self):
print(self.marks)
Learn all about Python Programming
University Exam Preparation Course
VINAY SIR SANCHIT SIR
obj=student()
print(obj._student__cgpa)
a.The program runs fine and 8.7 is printed
b.Error because private class members can’t be accessed
c. Error because the proper syntax for name mangling hasn’t been implemented
d. The program runs fine but nothing is printed
[wipro 2020]
5. Find the output :
print('ab cd-ef'.title())
a. Ab cd-ef
b. Ab Cd-ef
c. Ab Cd-Ef
d. None of the mentioned
[Accenture 2020]
Learn all about Python Programming
University Exam Preparation Course
VINAY SIR SANCHIT SIR
ANSWERS
1 (C) 2 (D) 3 (A) 4 (A) 5(C)
Ans. c
Explanation : Above code runs for
i=3j=1
i=4j=2
i=4j=1
i=5j=2
{(3, 1), (4, 1), (4, 2), (5, 2)}
Ans. d
Explanation : We created an object of class B that inherits class A and so disp()
method (of class A) becomes visible with reference to object obj. Option d is
correct
Ans. A
Explanation : Here the loop will execute 3 times i.e i=1,i=2,i=3. In each iteration,
count is incremented by 1.
Ans. a
Explanation : No issues with the code. It will work fine.
Ans. c
Explanation : title() : This method returns a string where the first character in
every word is upper case. Like a header, or a title.
Resume Preparation Training course
Interview Preparation course
YASH SIR SANCHIT SIR
To get 10% discount on GATE 2022 Full
course,
Use referral code
KGYT
on
SUBSCRIBE FOR FULL
COURSE
Telegram group links
Placement group GATE discussion group
VISIT OUR WEBSITE
YASH SIR SANCHIT SIR