Unit 3.5, 3.6 and 3.7 Booleans Expressions, Conditionals, Nested Conditionals Notes
Vocab
Function | Symbol |
---|---|
greater than | > |
less than | < |
greater than or equal to | >= |
less than or equal to | <= |
equal to | == |
not equal to | != |
Key Terms
- Boolean expression:TRUE or FALSE statement- Conditional: Handles conditions in your program
- Nested conditional: if or if else statement inside a different if else statement.
- Algorithm: A set of instructions that accomplish a task.
- Selection: The process that determines which parts of an algorithm is being executed based on a condition that is true or false.
Below is an example of decimal number to binary converter which you can use as a starting template.
def DecimalToBinary(num):
if num > 0:
DecimalToBinary(num // 2)
print(num % 2, end = "")
num = int(input("choose your number"))
print("The number: ", num, " converts to ", end = "")
DecimalToBinary(num)