WorksheetsUnderstanding Python Data Types
Total questions: 27
Worksheet time: 13mins
What are the four primitive data types in Python?
int, float, str, bool
int, float, list, tuple
char, double, list, dict
str, bool, set, complex
Which data type is used to represent whole numbers in Python?
float
string
int
boolean
What is the correct way to declare a variable in Python?
x : 10
var x = 10;
x = 10
let x = 10;
Which of the following is a valid variable name in Python?
1invalidVariable
invalid-variable-name
invalid variable name
valid_variable_name
What function would you use to check the type of a variable in Python?
type()
check_type()
var_type()
get_type()
What is the output of the expression type(3.14)?
Which data type is used to represent text in Python?
int
list
str
float
What is the purpose of the 'str()' function in Python?
The 'str()' function is used to perform mathematical operations.
The 'str()' function is for creating lists in Python.
The 'str()' function is used to define new data types.
The purpose of the 'str()' function is to convert values into their string representation.
Can variable names in Python start with a number?
Variable names can start with a special character
No
Only if they are enclosed in quotes
Yes, they can start with a number
What is the maximum length of a variable name in Python?
Up to 255 characters
Exactly 100 characters
There is no strict limit, but practical limits suggest around 79 characters.
No more than 50 characters
Which of the following is not a primitive data type in Python?
string
list
float
integer
What is the output of the expression len('Hello')?
6
10
4
5
What is the convention for naming variables in Python?
Variable names must always start with a number.
Variable names can only contain letters and numbers.
Variable names in Python should start with a letter or underscore, followed by letters, numbers, or underscores.
Variable names can include special characters like @ and #.
What function would you use to convert a string to an integer in Python?
int()
convert_string()
str_to_int()
parseInt()
Is it possible to use special characters in variable names in Python?
Only certain special characters are allowed in variable names in Python.
Yes, special characters can be used in variable names in Python.
No, special characters cannot be used in variable names in Python.
Special characters can be used if they are enclosed in quotes.
Python is an OOP language.
True
False
What is the output of the following code snippet? ```python print("Hello, Python!") ```
Hello, Python!
"Hello, Python!"
print("Hello, Python!")
Hello, World!
What is the Python code needed to display a word on the screen?
print"hello"
"hello"
print("hello")
print="hello"
What is the Python code needed to ask a user for input?
input("what is your name?")
input="what is your name?"
(input)=what is your name?
input=what is your name?
What does the Python data type str stand for?
string
integer
Boolean
float
What is the Python data type bool stand for?
string
integer
Boolean
float
What is the output of the following code?
x = 25
type(x)
integer
int
<class 'int'>
<class 'number'>
How to get the type of the following Variable?
Val = 12
type(Val)
exec(Val)
print(Val)
help(Val)
Which one of the following is False regarding data types in Python?
In python, explicit data type conversion is possible
Mutable data types are those that can be changed.
Immutable data types are those that cannot be changed.
None of the above
Which of these is not a core data type?
List
Tuple
Dictionary
Class
Which of the following is not a valid integer in Python?
0o123
123
0123
0x123
A variable is a named value that can be changed in the program.
False
True
