Python Basics Flashcards
Python Vocabulary
What is a variable in Python?
A variable is a reserved memory location to store values.
True or False: Python is a statically typed language.
False
What symbol is used for comments in Python?
#
Fill in the blank: In Python, a list is defined using ______.
square brackets []
What function is used to output data to the console in Python?
print()
What is a function in Python?
A block of reusable code that performs a specific task.
What keyword is used to define a function in Python?
def
True or False: Python supports multiple inheritance.
True
What is a dictionary in Python?
A collection of key-value pairs.
What does the ‘len()’ function do?
It returns the number of items in an object.
What is the purpose of the ‘if’ statement in Python?
To execute a block of code conditionally.
Fill in the blank: In Python, the ______ keyword is used to handle exceptions.
try
What is a module in Python?
A file containing Python definitions and statements.
What operator is used for exponentiation in Python?
**
True or False: Lists in Python are immutable.
False
What are tuples in Python?
Immutable sequences of values.
What does the ‘import’ statement do?
It allows you to include external modules in your code.
What is a class in Python?
A blueprint for creating objects that encapsulate data and behavior.
What is the purpose of the ‘self’ keyword in a class?
It refers to the instance of the class.
Fill in the blank: A ______ is a function defined inside a class.
method
What is a list comprehension in Python?
A concise way to create lists using a single line of code.
True or False: The ‘pass’ statement in Python does nothing.
True
What is the output of ‘2 + 3 * 4’ in Python?
14
What does the ‘break’ statement do in a loop?
It exits the loop prematurely.