Homework
- Notes from 3.5-3.7
- Frontend Version using html and javascript (click "view on github" to see actual code w comments)
Notes from 3.5-3.7
3.5 Important vocab
- Boolean
- Relational Operator
- Logical Operator
Boolean Operators: Produces booleans after used between 2 values
Relational Operators: These can work between any 2 values of the same type known as operands
Logical Operators: These are operators that works on operand(s) to produce a single boolean result
3.6 Algorithm - set of instructions that accomplish a certain task Selection - the process that determines which parts of an algoritm is being executed based on a condition Conditional - a statement that affects the outcome of a program by executing different statements based on the result of a true or false statement (boolean)
Examples of conditionals are if else statements
3.7 Nested Conditional statements - conditional statements within conditional statements
Below is an example of decimal number to binary converter which you can use as a starting template.
def DecimalToBinary(num):
strs = ""
while num:
if (num & 1):
strs += "1"
else:
strs += "0"
num >>= 1
return strs
def reverse(strs):
print(strs[::-1])
num = 67
print("Binary of num 67 is:", end=" ")
reverse(DecimalToBinary(num))
def DecimalToBinary(num):
decimal = 24
if num >= 1:
DecimalToBinary(num // 2)
print(num % 2, end = '')
if __name__ == '__main__':
decimal = 24
DecimalToBinary(decimal)