Q1.Which of the following is the use of id() function in python ?
Every object doesn’t have a unique id
Id returns the identity of the object
All of the mentioned
None of the mentioned.
Answer:- (2).
Q2.All keywords in Python are in ?
Upper Case
Lower Case
Capitalized
None of the mentioned.
Answer:- (4).
Q3. What is the return type of function id ?
float
bool
dict
int
Answer:- (4).
Q4. Which of the following data types is not supported in python ?
String
Numbers
slice
list
Answer:- (3).
Q5. which are the reserved keywords in python ?
else
raise
import
all of the above
Answer:- (4).
Q6. Which statement is correct ?
List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both are Mutable.
Both are Immutable
Answer:- (1).
Q7.What is the maximum possible length of an identifier ?
32
63
79
31
Answer:- (4).
Q8.What will be the output of 7^10 in python ?
13
15
2
none of these
Answer:- (1).
Q9.Which of the following refers to mathematical function ?
sqrt
add
math
sum
Answer:- (1).
Q10.Which one of these is floor division operator ?
/
//
%
$
Answer:- (2).
Q11.Python supports the creation of anonymous functions at runtime, using a construct called __________ ?
pi
anonymous
lambda
none of the mentioned.
Answer:- (3). Explanation :Python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called lambda. Lambda functions are restricted to a single expression. They can be used wherever normal functions can be used.
Q12.what does pip stands for python ?
Unlimited length
all private members must have leading and trailing underscores.
Answer:- (4). Explanation :For order of precedence, just remember this PEMDAS (similar to BODMAS).
Q14. Which of the following functions is a built-in function in python ?
factorial()
print()
seed()
sqrt()
Answer:- (2). Explanation :The function seed is a function which is present in the random module. The functions sqrt and factorial are a part of the math module. The print function is a built-in function which prints a value directly to the system output.
Q15. Which of these is the definition for packages in Python ?
a set of main module
a folder of python modules
a number of files containing python definitions and statements
a set of programs making use of Python modules
Answer:- (2). Explanation :A folder of python programs is called as a package of modules.
Q16. Which function is called when the following python program is executed ?
f = foo()
format(f)
str()
format()
_str_()
_format_()
Answer:- (3). Explanation :Both str(f) and format(f) call f.
Q17. Which one of the following is not a keyword in python language ?
pass
eval
assert
nonlocal
Answer:- (2). Explanation :Eval can be used as a variable.
Q18.what will be the output of the following Python code ?
print("abc. DEF .capitalize())
Abc. def
abc. def
Abc. Def
ABC. DEF
Answer:- (1). Explanation :The first letter of the string is converted to uppercase and the other are converted to lowercase.
Q19. Which of the following python statements will result in the output: 6 ?
A=[[1, 2, 3],
[4, 5, 6]
[7, 8, 9]]
A[2][1]
A[1][2]
A[3][2]
A[2][3]
Answer:- (2). Explanation :The output that is required is 6, that is, row 2, item 3.This position is represented by A[1][2].
Q20.What will be the output of the following python code snippet ?
z=set('abc$de')
'a' in z
Error
True
False
No output
Answer:- (2). Explanation : The code shown above is used to check whether a particular item is a part of a given set or not. Since 'a' is a part of the set z, the output is true. Note that this code would result in an error in the absence of the quote.
Q21.what are the two main types of functions in python ?
system function
custom function
built in function & user defined function
user function
Answer:- (3).
Q22.What will be the output of the following Python Code ?
print("Hello {0[0]} and {0[1]}" .format(('foo', 'bin')))
Hello('foo', 'bin') and ('foo', 'bin')
Error
Hello foo and bin
None of the mentioned.
Answer:- (3). Explanation : The elements of the tuple are accessed by their indices.
Q23. The process of pickling in python includes_______ ?
Conversion of a python object hierarchy into byte stream
Conversion of a datatable into a list
Conversion of a byte stream into python object hierarchy
Conversion of a list into a datatable
Answer:- (1). Explanation : Pickling is the process of sterilizing a python object, that is, conversion of a byte stream into python
object hierarchy. The reverse of this process in known as unpickling.
Q24. What will be the output of the following python code ?