1. Consider the snippet of code shown below and predict the output.
X=”san-foundry” print(“%56s”,X)
a. 56 blank spaces before san-foundry
b. 56 blank spaces before san and foundry
c. 56 blank spaces after san-foundry 1
2. What Relationship Correctly Fits For University And Professor?
a. Inheritance
b. association
c. composition
3. Which of these is false about recursion?
a. Recursive functions run faster than non-recursive function
b. Recursive functions usually take more memory space than non-recursive function
Recursive function can be replaced by a non-recursive function
4. Which of these in not a core datatype?
a. Lists
b. Dictionary
c. Class
5. Which of the following function convert a string to a float in python?
a. long(x [,base] )
b. float(x)
c. int(x [,base])
6. What Relationship Is Suited For Course And Faculty?
a. inheritance
b. composition
c. association
7. Which of these is not a core data type?
a. Lists
b. Dictionary
c. Class
8. All subclasses are a subtype in object-oriented programming. Is the statement true or
false?
a. TRUE.
b. FALSE.
9. What is the output of the following code : print 9//2
a. 5
b. 4.5
c. 4
d. 9
10. What does print(Test.name) display (assuming Test is the name of the class) ?
a. ()
b. Exception is thrown
c. Test
11. What Will Be The Output Of The Following Code Snippet? class Sales: def init(self, id):
self.id = id id = 100
val = Sales(123) print (val.id)
a. SyntaxError, this program will not run
b. 100
c. 123
12. What Relationship Is Best Suited For House And Door?
a. Association
b. inheritance
c. Composition
13. Which Of The Following Represents A Distinctly Identifiable Entity In The Real World?
a. A method
b. An object
c. A class
14. What is setattr() used for?
a. To access the attribute of the object
b. To set an attribute
c. To check if an attribute exists or not 2
15. What dataype is the object below ? L = [1, 23, ‘hello’, 1].
a. list
b. dictionary
c. array
16. Following set of commands are executed in shell, what will be the output?
str="hello"
str[:2]
a. lo
b. he
c. olleh
17. What are the values of the following expressions:
18. 2**(32) (23)2 23**2
a. 64, 512, 64
b. 512, 512,
c. 512 512, 64, 512
19. When defining a subclass in Python that is meant to serve as a subtype, the subtype
Python keyword is used. Is the statement true or false?
a. TRUE.
b. FALSE.
20. Which function overloads the >> operator?
a. more()
b. gt()
c. none of these
21. A class in which one or more methods are only implemented to raise an exception is
called an abstract class. True or False?
a. TRUE.
b. FALSE.
22. What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
a. vi) Subtraction
b. i,ii,iii,iv,v,vi
c. ii,i,iii,iv,v,vi
d. ii,i,iv,iii,v,vi
23. What is called when a function is defined inside a class?
a. Method
b. Another
c. Function Module
24. What is the output of the following program : y = 8 z = lambda x : x * y print z(6)
a. 48
b. 16
c. 64
25. Which keyword is use for function?
a. Def
b. Define
c. Fun
26. What is the type of each element in sys.argv?
a. Tuple
b. string
c. list
27. Which Of The Following Represents A Template, Blueprint, Or Contract That Defines
Objects Of The Same Type?
a. An object
b. A class
c. A method
28. All keywords in Python are in
a. uppercase
b. lowercase
c. none of these
29. What data type is the object below ? L = [1, 23, ‘hello’, 1]
a. List
b. Dictionary
c. Array
30. Which function overloads the // operator?
a. floordiv()
b. ceildiv()
c. div()
31. del method is used to destroy instances of a class. True or False?
a. TRUE.
b. FALSE.