Interview Questions and Answers
MCQ Format
Created by: Manish Dnyandeo Salunke
Online Format: https://bit.ly/online-courses-tests
Which Python built-in function would you use to convert
a string into a number, if possible?
Option 1: int()
Option 2: str()
Option 3: list()
Option 4: float()
,Correct Response: 1
Explanation: The int() function is used to convert a string into an integer, if
possible, while float() is used to convert a string into a float number. str()
converts other data types to string and list() converts other types to list.
, What would be the output of the following Python code?
print(type([]))
Option 1: <class 'list'>
Option 2: <class 'str'>
Option 3: <class 'int'>
Option 4: <class 'tuple'>
Correct Response: 1
Explanation: The output of type([]) would be <class 'list'> because the
empty square brackets represent an empty list, so the type() function returns
<class 'list'>.