1/20
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Boolean
A value which is true or false; it is a variable type.
What does type(True) return?
bool (indicating Boolean type).
What is str(True) used for?
To convert a Boolean to a true value type (string).
What is an if statement?
Runs a program on specific conditions.
What is the syntax of an if statement?
if (condition): # code block else: # code block
What should I know about the if branch?
Prints something if the condition is met and must evaluate to a Boolean (True or False).
What should I know about the elif branch?
It has a condition and only runs if the first if condition is not met.
What should I know about the else branch?
Executes the program if the condition in if and elif is not met; no specific condition is required.
What are the comparison operators in Python?
How do you check if more than one condition is true?
Use and or or.
What is the order of the alphabet when comparing strings?
Symbols/numbers, Uppercase letters, Lowercase letters.
How do you compare strings in Python?
== : equal to; != : not equal to; < : earlier in dictionary order; > : later in dictionary order.
Given x = 5, what is the result of x < 10?
True.
What are the logical operators in Python?
not : Changes a true value to false; and : True if both conditions are true; or : True if at least one condition is true.
What is a truth table?
Shows values of Boolean expressions given x and y; used to analyze logic in expressions.
What is a Venn Diagram used for in logical operators?
Visually shows logical operators.
Why do we use the round command?
Because Python sometimes rounds very weirdly; it’s used to round a number to a specific decimal value.
What does round(value, decimals) do?
Rounds a number to a given number of decimal places.
What is float in Python?
Changes an element to a float type (decimal).
How do you generate a random number?
Use randint inside of a random function; imports the random library.
What is a package in Python?
Organizes related modules into a hierarchical structure.