Python Programming Quiz – 8th Week Quiz Solution 2020
Important Notes:-
Hello Dosto Please Subscribe Our Youtube channel Because Copyright Problem In this post ( python / css / Al / nptel ) So please i humble Request Subscribe Our channel or social Networks ( than we are all are connect To each and every person ) These are Our youtube channel My Youtube Channel .. only 321 subscribe in my youtube channel .( channel ko subscribe kar lo kyuki kabhi bhi website band ho sakti hai sar post 2019 se ho rhe hai or answer sare senior ke dwara batye hue hai ) . youtube channel ko jaldi se share karo tak jada subscribe ho jaye to copyright ka koi problem na ho .. thanks
[1] A class definition in python begins with the keyword –
(a): def , file
(b): class , object
(c): self , py file
(d): None of these
Answer: (b) class , object
Reason:- Python is an “object-oriented programming language.” This means that almost all the code is implemented using a special construct called classes. ... This is done using the keyword “class,” which is a grouping of object-oriented constructs. By the end of this tutorial you will be able to: Define what is a class.
Q-2. What will be the output of the following python code ?
class Roll:
def __init__(self, id):
self.id = id
id = 231
return id
val = Roll(321)
print (val.id).
(a): TypeError
(b): 231
(c): 321
(d): None of these
Answer: (b): 231
Reason:- its return value id 231 because the id is already is given this code so its output of 231.
[3] What will be the output of following python code?
class X:
def __init__(self):
self.a = 10
self._b = 20
def getB(self):
return self._b
x = X()
x._b = 60
print(x.getB())
(a): 20
(b): 60
(c): Error
(d): Program runs but does not print anything
Answer: (b) 60
Reason:- 60 is the output of following python code because this code is right .
4.private method starts with _______ while protected method starts with ________.
(a).#,@
(b).double underscore,single underscore
(c).single underscore , double underscore
(d).None of these
Answer:- (b).double underscore,single underscore.
Reason:- In Python, there is no existence of Private methods that cannot be accessed except inside a class. However, to define a private method prefix the member name with double underscore ,The culture in Python is that names starting with underscores mean, "don't use these unless you really know you should." You might choose to begin your "protected" methods with underscores.
5. what will be the output of the following code. code is saved in a file named 'code.py'
f = open(‘file.txt’)
f, readlines()
print(f. name)
print ( f.closed )
f.close()
print ( f.closed ).
(a).Error in code
(b). true
false
true
(c). code.py
False
True
(d)file.txt
False
True
Answer;- (d)file.txt
False
True
Reason:- this is 3 function and first is file.txt and closed , named its is defined The readlines() method returns a list containing each line in the file as a list item. Use the hint parameter to limit the number of lines returned.
The close() method closes an open file. You should always close your files, in some cases, due to buffering, changes made to a file may not show until you close the file
8 Comments
This comment has been removed by the author.
ReplyDeletequestion me khud se type kiya hu kuch galt hogya hoga
Deletebaki anaswer sahi hai
Bhai week 9 upload kr do
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteBhai quiz 9 upload kardo jaldi se.
ReplyDeleteVery informative article post. Really looking forward to read more. Keep writing.
ReplyDeletemoral alignment test
I once went to a bar quiz and there was an inquiry thusly: What is the name of the attorney living at No. 10 Downing Street (at the time Tony Blair was PM)? am i a narcissist
ReplyDeleteI propose £1 per player. Assuming you get a truly well known quiz moving and do large prizes, you may charge more. celebrity look alike
ReplyDelete