21. If x=3.123, then int(x) will give ?
- 3.1
- 0
- 1
- 3
Answer : D Explanation: int() will convert the float value into integer value.
22. Which of the following is the example of typecasting?
- int(5)
- str(5)
- str(xyz)
- All of the above
Answer : D Explanation: All
23. What is type casting in python?
- Declaration of data type
- Destroy data type
- Change data type property
- None of the above
Answer : C Explanation: Type casting means changing the property of data types.
24. In Python 3, the maximum value for an integer is 263 – 1:
- True
- Flase
Answer : B Explanation: In Python 2, there was an internal limit to how large an integer value could be. But that limit was removed in Python 3.This means there is no explicitly defined limit, but the amount of available address space forms a practical limit depending on the machine Python runs on.
25. Which of the following is not a data type in python?
- List
- Tuple
- Dictionary
- Book
Answer : D Explanation: Book is not a data type
26. Which of the following is a valid way to specify the string literal foo'bar
in Python:
- “foo’bar”
- ‘foo”bar’
- ‘foo’bar’
- None of the above
Answer : A
27. Correct way to declare a variable x of float data type in python:
- x = 2.5
- float x = 2.5
- float(2.5)
- All of the above
Answer : A Explanation: We just write the variable name and can assign any type of value and then the type of variable will change according to the value we assign in it.
28. All keywords in Python are in ____
- None of the below
- lower case
- UPPER CASE
- Capitalized
Answer : A Explanation: True, False, and None are capitalized while the others are in lower case.
29. Which of the following is true for variable names in Python?
- Underscore and ampersand are the only two special characters allowed
- All private members must have leading and trailing underscores
- Unlimited length
- none of the mentioned
Answer : C Explanation: Variable names can be of any length.
30. What does ~4 evaluate to?
- -4
- -5
- -3
- +3
Answer : B Explanation: ~x is equivalent to -(x+1).
31. In order to store values in terms of key and value we use that core data type in python?
- List
- Class
- Dictionary
- Tupple
Answer : C Explanation: Dictionary is the collection of keys and their value.
32. How can we get 6 from the given list: list=[9,5,6,3]
- list[-2]
- list[-1]
- list[3]
- None of the above
Answer : A Explanation: list[-2] will give the second last element of the list.
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