Python Variables, Data Types & Keywords
Python Variables, Data Types & Keywords Interview Questions
Fill in the blanks
Values are assigned to names using the ________ operator.
Show answer
Answer: assignment (=)
Python uses ______________ typing: variable types are determined when values are assigned.
Show answer
Answer: dynamic
By convention, multi-word variable names use ______________ case (lowercase with underscores).
Show answer
Answer: snake
The built-in function ________ returns the data type of an object.
Show answer
Answer: type
The singleton object that means “no value” is ________.
Show answer
Answer: None
Whole numbers such as 42 have type ________.
Show answer
Answer: int
Floating-point numbers such as 3.14 have type ________.
Show answer
Answer: float
The two Boolean literals in Python are ________ and ________.
Show answer
Answer: True, False
Python strings are ______________: you cannot change individual characters in place.
Show answer
Answer: immutable
Lists are ______________: items can be added, removed, or replaced.
Show answer
Answer: mutable
Key–value pairs are stored in a ________.
Show answer
Answer: dictionary (dict)
An unordered collection of unique elements is a ________.
Show answer
Answer: set
Names assigned inside a function are usually ________ to that function unless declared otherwise.
Show answer
Answer: local
To assign to a global variable inside a function, use the ________ keyword.
Show answer
Answer: global
Use ________ to compare values for equality; use is to test whether two names refer to the same object.
Show answer
Answer: ==