11. In Python, a variable must be declared before it is assigned a value:
- True
- False
Answer : B Explanation: Variables need not be declared or defined in advance in Python programming. To create a variable, you just assign it a value.
12. Why does the name of local variables start with an underscore discouraged?
- To identify the variable
- It confuses the interpreter
- It indicates a private variable of a class
- None of these
Answer : C Explanation: Since there is no concept of private variables in Python language, majorly underscore is used to denote variables that cannot be accessed from outside the class.
13. Which of the following will run without errors?
- round(75.8)
- round()
- round(5352.898,9,5)
- round(6463.123,2,6)
Answer : A Explanation: Execute help(round) in the shell to get details of the parameters that are passed into the round function.
14. Which of the following is a valid variable?
- var@
- 32var
- in
- abc_x
Answer : D Explanation: Variable name should not be a keyword, cannot begin with a digit, and should not contain any special symbol. Hence D is the correct identifier or variable. So, Option D is correct.
15. Is Python case sensitive when dealing with identifiers?
- Yes
- No
- Machine dependent
- None of the above
Answer : A Explanation: Case is always significant.
16. In which data type, indexing is not valid?
- List
- String
- Dictionary
- None of the above
Answer : C Explanation: Indexing is not valid in dictionary.
17. Select the correct example of complex datatype in Python
- 3 + 2j
- -100j
- 5j
- All of the above are correct
Answer : D Explanation: All of the above are complex data types in python
18. What is output of: 35 == 35.0
- False
- True
- 33
- None of the above
Answer : B Explanation: comparison operator (==) evaluates true and false. And in python, we need not specify whether the number is int or float.
19. l = [ 4, 8, 9, 2.6, 5 ] is a type of which data type in python?
- List
- Tuple
- Set
- None of these
Answer : A Explanation: List in python is created by writing values inside [].
20. How can we create an empty list in python?
- list=()
- list.null
- null.list
- list=[]
Answer : D Explanation: List in python is created by writing values inside []. So, for creating an empty list just leave the list as [].
Pingback: Python Basics (Multiple Choice Questions) MCQ - Python Interview objective questions| Python Quiz - cozmocard
Pingback: MS Excel MCQ Questions And Answers - cozmocard
Pingback: Java MCQ Questions and Answers - cozmocard
Pingback: Advance Java MCQ Questions and Answers - cozmocard
Pingback: Top Python Interview Questions And Answers - cozmocard