1/53
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
How do you assign a value to a variable in Python?
Use variable_name = value.
Difference between int, float, and str?
int = whole numbers, float = decimals, str = text.
How do you concatenate two strings?
"hello" + "world".
What does input() do?
Reads user input and returns it as a string.
What does type() do?
Shows the data type of a value or variable.
Convert "25" to an integer.
int("25").
How do you write a comment in Python?
Use #.
Convert a string to lowercase.
s.lower().
How do you find the length of a string or list?
len().
What does len() return?
Number of items/characters.
What’s the purpose of an if-else statement?
To run different code depending on a condition.
What is elif used for?
Multiple conditions when if isn’t true.
Difference between and and or?
and: both conditions must be true; or: at least one must be true.
What does not do?
Reverses a Boolean value.
Structure of a while loop?
while condition: code.
How does a for loop work?
Iterates over items in a sequence (list, string, range).
Purpose of break?
Stops a loop immediately.
Purpose of continue?
Skips to the next loop iteration.
Print numbers 1–10 using a loop.
for i in range(1, 11): print(i).
Difference between list and dictionary?
List uses indexes; dictionary uses key-value pairs.
Create an empty list.
[] or list().
Append to a list.
lst.append(item).
Remove last item in a list.
lst.pop().
Access first list element.
lst[0].
Access last list element.
lst[-1].
Reverse a list using slicing.
lst[::-1].
Add an item to a dictionary.
d[key] = value.
Check if value exists in list.
value in lst.
Combine lists.
list1 + list2.
Check if string contains substring.
"cat" in s.
Count vowels in a string (core idea).
Loop through characters and count "aeiou".
Split string into words.
s.split().
Remove whitespace on ends.
s.strip().
Reverse a string.
s[::-1].
What does find() do?
Returns index of substring or -1 if not found.
Replace substring.
s.replace("old", "new").
Convert to uppercase.
s.upper().
Check if string is numeric.
s.isdigit().
Format a string.
f"Hello {name}".
Purpose of return?
Sends a value back from a function.
How to define a function?
def function_name(params): code.
Function that returns sum of two numbers.
def add(a, b): return a + b.
Function that takes list and returns average.
sum / length.
What is an algorithm?
Step-by-step process to solve a problem.
Find minimum in a list?
Loop through, track smallest so far.
Sum elements in a list?
Use sum(lst) or loop and add.
Convert Celsius → Fahrenheit.
F = C * 9/5 + 32.
What is a local variable?
A variable created inside a function.
Number of parameters in def t(a,b,c,d)?
4.
How does binary search work?
Repeatedly splits sorted list in half to find a target.
What happens if list is not sorted?
Binary search fails / returns incorrect results.
How does insertion sort work?
Builds sorted list one element at a time by inserting into correct position.
Why sort a list?
Makes searching faster, organizes data.
Alternatives to insertion sort?
Bubble sort, Selection sort, Merge sort, Quick sort.