Question
1. How are variable length arguments specified in the function heading? a) one star followed by a valid identifier b) one underscore followed by a
1. How are variable length arguments specified in the function heading?
a) one star followed by a valid identifier
b) one underscore followed by a valid identifier
c) two stars followed by a valid identifier
d) two underscores followed by a valid identifier
2. What will be the output of the following Python code?
def find(a, **b):
print(type(b))
find('letters',A='1',B='2')
a) String
b) Tuple
c) Dictionary
d) An exception is thrown
3. What will be the output of the following Python code?
>>> a=dict()
>>> a[1]
a) An exception is thrown since the dictionary is empty
b) ' '
c) 1
d) 0
4. What is math.floor(0o10)?
a) 8
b) 10
c) 0
d) 9
5. Special methods need to be explicitly called during object creation.
a) True
b) False
6. What will be the output of the following Python code?
def f():
global a
print(a)
a = "hello"
print(a)
a = "world"
f()
print(a)
a)
hello
hello
world
b)
world
hello
hello
c)
hello
world
world
d)
world
hello
world
7. Which of the following statements is true?
a) The standard exceptions are automatically imported into Python programs
b) All raised standard exceptions must be handled in Python
c) When there is a deviation from the rules of a programming language, a semantic error is thrown
d) If any exception is thrown in try block, else block is executed
8. What does os.name contain?
a) the name of the operating system dependent module imported
b) the address of the module os
c) error, it should've been os.name()
d) none of the mentioned
9. What will be the output of the following Python code?
def f1():
x=15
print(x)
x=12
f1()
a) Error
b) 12
c) 15
d) 1512
10. Methods of a class that provide access to private members of the class are called as __ and __
a) getters/setters
b) repr__/__str
c) user-defined functions/in-built functions
d) init__/__del
11. What will be the output shape of the following Python code?
import turtle
t=turtle.Pen()
for i in range(0,4):
t.forward(100)
t.left(120)
a) square
b) rectangle
c) triangle
d) kite
12. What will be the output of the following Python code?
class A:
def __init__(self):
self.__i = 1
self.j = 5
def display(self):
print(self.__i, self.j)
class B(A):
def __init__(self):
super().__init__()
self.__i = 2
self.j = 7
c = B()
c.display()
a) 2 7
b) 1 5
c) 1 7
d) 2 5
13. What is the use of "a" in file handling?
a) Read
b) Write
c) Append
d) None of the mentioned
14. What will be the output of the following Python code?
w = re.compile('[A-Za-z]+')
w.findall('It will rain today')
a) 'It will rain today'
b) ('It will rain today')
c) ['It will rain today']
d) ['It', 'will', 'rain', 'today']
15. Which of the following functions results in an error?
a) turtle.shape("turtle")
b) turtle.shape("square")
c) turtle.shape("triangle")
d) turtle.shape("rectangle")
16. What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?
import datetime
tday=datetime.date.today()
print(tday)
a) 18-06-2017
b) 06-18-2017
c) 2017-06-18
d) Error
17. What is the current syntax of remove() a file?
a) remove(file_name)
b) remove(new_file_name, current_file_name,)
c) remove(() , file_name))
d) none of the mentioned
18. What does math.sqrt(X, Y) do?
a) calculate the Xth root of Y
b) calculate the Yth root of X
c) error
d) return a tuple with the square root of X and Y
19. The output of the following codes are the same.
[x**2 for x in range(10)]
list(map((lambda x:x**2), range(10)))
a) True
b) False
20. The special character \B matches the empty string, but only when it is _________
a) at the beginning or end of a word
b) not at the beginning or end of a word
c) at the beginning of the word
d) at the end of the word
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started