Python Flashcards
(71 cards)
What is the syntax to output ‘Hello, World!’ in Python?
print(‘Hello, World!’)
True or False: Python is a statically typed language.
False
Fill in the blank: In Python, a variable can be declared by assigning a value using the ____ operator.
=
What data type is used to represent a sequence of characters in Python?
String
What is the keyword used to define a function in Python?
def
True or False: Lists in Python are immutable.
False
What is the output of the expression 3 * ‘Python’?
‘PythonPythonPython’
What symbol is used for comments in Python?
#
What is the default return value of a function in Python that does not return anything?
None
What data type would you use to store a collection of unique items in Python?
Set
What is the method to add an item to a list in Python?
.append()
What is the syntax for an if statement in Python?
if condition:
True or False: Tuples are mutable in Python.
False
What is the correct way to create a dictionary in Python?
{}
What does the len() function do in Python?
Returns the number of items in an object.
What keyword is used to create a class in Python?
class
What is the output of 5 // 2 in Python?
2
What is the syntax to import a module named ‘math’?
import math
Fill in the blank: In Python, the ____ statement is used to handle exceptions.
try
What is the result of the expression ‘5’ + ‘6’ in Python?
‘56’
True or False: The ‘break’ statement is used to exit a loop in Python.
True
What operator is used for exponentiation in Python?
**
What is the output of the expression [1, 2] + [3, 4]?
[1, 2, 3, 4]
What is the syntax for a while loop in Python?
while condition: