Homework
Notes
- Nested Conditional Statements consist of conditional statemetns within conditional statements.
- If Else Statements can be put inside of another if else statement using this layout for psuedo code.
- algorithm - A set of instructions that accomplish a task.
- selection - The process that determines which parts of an algoritm is being executed based on a condition that is true or false.
- A conditional is a statement that affects the flow/outcome of a program by executing different statements based on the result of a true or false statement. That true or false statement is a boolean expression.
- In almost every programming language, if/else statements fill in the role of the conditional. Some languages call this switch blocks but if/else is the most used term.
Below is an example of decimal number to binary converter which you can use as a starting template.
decimal = int(input("pick a number"))
def convert(dec):
bin = ""
i = 7
while i >= 0:
if dec % (2**i) == dec:
bin = bin + "0"
i -= 1
else:
bin = bin + "1"
dec -= 2**i
i -= 1
print(bin)
convert(decimal)