Question - 1
What will be the output of the following Python expression if x=56.236?
print("%.2f"%x)
- 56.236
- 56.23
- 56.0000
- 56.24
Solutions
Answer- D
Question - 2
Which of these is the definition for packages in Python?
- A set of main modules
- A folder of python modules
- A number of files containing Python definitions and statements
- A set of programs making use of Python modules
Solutions
Answer- B
Question - 3
What will be the output of the following Python function?
len(["hello",2,4,6])
Answer- C
Question - 4
What is the order of namespaces in which Python looks for an identifier?
- Python first searches the built-in namespace, then the global namespace and finally the local namespace
- Python first searches the built-in namespace, then the local namespace and finally the global namespace
- Python first searches the local namespace, then the global namespace and finally the built-in namespace
- Python first searches the global namespace, then the local namespace and finally the built-in namespace
Solutions
Answer- C
Question - 5
What will be the output of the following Python statement?
f = foo()
format(f)
- str()
- format()
- __str__()
- __format__()
Solutions
Answer- C
Question - 6
Which one of the following is not a keyword in Python language?
- pass
- assert
- eval
- nonlocal
Solutions
Answer- C
Question - 7
What will be the output of the following Python code?
-
class tester:
-
def __init__(self, id):
-
self.id = str(id)
-
id="224"
-
-
>>>temp = tester(12)
-
>>>print(temp.id)
Answer- A
Question - 8
Which module in the python standard library parses options received from the command line?
Answer- B
Question - 9
What arithmetic operators cannot be used with strings in Python?
Answer- B
Question - 10
To add a new element to a list we use which Python command?
- list1.addEnd(5)
- list1.addLast(5)
- list1.append(5)
- list1.add(5)
Solutions
Answer- C
Question - 11
Study the following function:
round(4.576)
What will be the output of this function?
Answer- D
Question - 12
How many control statements python supports?
- Four
- Five
- Three
- None of the above
Solutions
Answer- C
Question - 13
Which of the following keywords is not reversed keyword in python?
Answer- C
Question - 14
PVM is often called _________.
- Python interpreter
- Python compiler
- Python volatile machine
- Portable virtual machine
Solutions
Answer- A
Question - 15
Which of the following keywords is used for function declaration in Python language?
- def
- function_name
- define
- None of these
Solutions
Answer- A
Question - 16
Which of the following objects are present in the function header in python?
- Function name and Parameters
- Only function name
- Only parameters
- None of these
Solutions
Answer- A
Question - 17
When a user does not use the return statement inside a function in Python, what will return the function in that case.
Answer- C
Question - 18
Which one of the following is the right way to call a function?
- call function_name()
- function function_name()
- function_name()
- None of these
Solutions
Answer- C
Question - 19
Suppose a user wants to print the second value of an array, which has 5 elements. What will be the syntax of the second value of the array?
- array[2]
- array[1]
- array[-1]
- array[-2]
Solutions
Answer- B
Question - 20
Which of the following statements is not valid regarding the variable in python?
- The variable_name can begin with alphabets
- The variable_name can begin with an underscore
- The variable_name can begin with a number
- None of these
Solutions
Answer- C
Practice more set questions