1/64
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
"What is a function in Python?"
"A reusable block of code that performs a specific task. It is defined using def and can take inputs (parameters) and return outputs."
"What does a return statement do?"
"It exits a function and optionally sends a value back to the caller."
"What are parameters in a Python function?"
"Variables listed inside the parentheses in a function definition that receive values when the function is called."
"What are arguments?"
"The actual values passed to a function's parameters when it is called."
"What are type hints in Python?"
"Optional annotations that indicate expected data types for readability and type checking tools like mypy. They are not enforced at runtime."
"What is the purpose of the colon (:) after a function definition line?"
"It starts the function block — Python uses indentation instead of braces to define scope."
"What is indentation used for in Python?"
"To define blocks of code such as function bodies, loops, and conditionals. Incorrect indentation causes errors."
"What is a dictionary in Python?"
"An unordered collection of key–value pairs where each key must be unique."
"What happens if a dictionary key already exists and you assign it a new value?"
"The old value is overwritten — keys are unique."
"What happens if you assign a new key to a dictionary?"
"Python creates a new key–value pair automatically."
"What are lists in Python?"
"Ordered, mutable collections of items that can hold different data types."
"What are sets in Python?"
"Unordered collections of unique items — duplicates are automatically removed."
"What are tuples in Python?"
"Ordered, immutable sequences of values."
"What does list.append(x) do?"
"Adds item x to the end of the list."
"What does len() do?"
"Returns the number of items in a sequence or collection."
"What does `split(',')` do on a string?"
"Splits the string into parts using a comma as the separator and returns a list of substrings."
"What does .strip() do?"
"Removes whitespace or specified characters from the start and end of a string, but not spaces in the middle."
"What does .lower() do?"
"Returns a lowercase version of the string."
"What does .upper() do?"
"Returns an uppercase version of the string."
"What does .isdigit() check?"
"Returns True if all characters in the string are digits."
"What does .isalpha() check?"
"Returns True if all characters in the string are letters."
"What does .isupper() check?"
"Returns True if all letters in the string are uppercase."
"What does `with open(filename, 'r') as file:` do?”
"Opens a file for reading using a context manager, ensuring it closes automatically after use."
"What does file.readline() do?"
"Reads one line from a text file."
"What does for line in file: do?"
"Iterates over each line in the file one by one."
"What does int(input('Enter a number: ')) do?"
"Prompts the user for input, converts the input string to an integer."
"What does print() do?"
"Displays text or variables to the console."
"What does input() do?"
"Pauses program execution to receive text input from the user as a string."
"What is a Boolean value?"
"A value that is either True or False."
"What are comparison operators in Python?"
"Operators used to compare values: ==, !=, <, >, <=, >=."
"What are logical operators in Python?"
"Operators that combine Boolean expressions: and, or, not."
"What does and return?"
"True only if both conditions are True."
"What does or return?"
"True if at least one condition is True."
"What does not do?"
"Inverts a Boolean value (True becomes False, False becomes True)”
"What does if do in Python?"
"Executes code only if a condition is True."
"What does elif mean?"
"Short for 'else if' — checks another condition if the previous one was False."
"What does else do?"
"Specifies a block of code to run if none of the previous conditions are True."
"What does while do?"
"Repeats code as long as a condition is True."
"What does for do?"
"Iterates over each item in a sequence like a list, string, or range.”
"What does continue do in a loop?"
"Skips the rest of the current iteration and goes to the next one."
"What does break do in a loop?"
"Exits the loop immediately
"What is a flag variable?"
"A variable (often Boolean) used to track whether a certain condition has been met."
"What is an infinite loop?"
"A loop that never ends because its condition always remains True (e.g., while True:)."
"What does try and except do?"
"Used to handle exceptions (errors) gracefully, preventing the program from crashing.”
"What is FileNotFoundError?"
"An error that occurs when trying to open a file that doesn’t exist."
"What does except Exception: do?"
"Catches any kind of error that wasn’t specifically handled."
"What does exit() do?"
"Stops program execution immediately."
"What does += do?"
"Adds a value to a variable and stores the result in the same variable (e.g.
"What does * do when used with strings (e.g.'=' * 50)?"
“Creates a string made up of 50 equal signs."
"What is the difference between = and ==?"
"= assigns a value; == compares two values for equality."
"What does time * focus represent in an expression?"
"It multiplies two numeric values — often used for calculations like scores or totals."
"What is a float in Python?"
"A number that has a decimal point
"What is an integer in Python?"
"A whole number without a decimal point
"What is the purpose of indentation in loops and conditionals?"
"To indicate which statements belong to the block "
"What happens if indentation is inconsistent in Python?"
"It raises an IndentationError."
"What does range(5) generate?"
"A sequence of numbers from 0 up to (but not including) 5."
"What is the purpose of comments (lines starting with #)?"
"They explain code to humans and are ignored by Python when running."
"What is the purpose of separating logic into functions?"
"It improves readability, reusability, and organization of code.”
"What is the difference between mutable and immutable data types?"
"Mutable types (like lists and dicts) can be changed after creation; immutable types (like strings and tuples) cannot."
"What happens when you pass a dictionary to a function and modify it inside?"
"The changes affect the original dictionary because it’s mutable and passed by reference."
"What is the in operator used for?"
"Checks if a value exists in a sequence (like a list
"What does .append() do for lists?"
"Adds an element to the end of the list."
"What is the purpose of get() in dictionaries?"
"Retrieves the value of a key if it exists
"What is the general purpose of using functions and loops together?"
"To organize repeated tasks and automate data processing efficiently."
"What does it mean when Python is 'dynamically typed'?"
"Variables don’t have fixed types — their type can change at runtime based on the value assigned."