Score of 0.9/1

VOCAB!:

  • Boolean Operators: produces booleans after it is used between two values
  • Relational Operators: can work between any two values of the same type known as operands, provided that the type supports such types of operators
  • Logical Operators: operators that works on operand(s) to produce a single boolean result. Examples include and, or, not.
  • 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
  • Nested Conditionals: consist of conditional statements within conditional statements

Homework

our homework we have decided for a decimal number to binary converter. You must use conditional statements within your code and have a input box for where the decimal number will go. This will give you a 2.7 out of 3 and you may add anything else to the code to get above a 2.7

def DecimalToBinary(decimal):
    binary = 0
    ctr = 0
    temp = decimal  #copy input decimal
    #find binary value using while loop
    while(temp > 0):
        binary = ((temp%2)*(10**ctr)) + binary
        temp = int(temp/2)
        ctr += 1
    return binary

 
# Driver Code
num = int(input("Enter a number to convert to binary: "))
print("Binary of " + str(num) + " is:", end=" ")
DecimalToBinary(num)
Binary of 67 is: 
1000011