# Noemi Cabrera
# 28 September 2021
# In this lesson, I learned to use the basic math operators when wrting code.
# The order of operations for regular math is the same in Python. I also practiced casting numeric user input to
# integer form. I learned that you can code more than two choices in if/se statements by using the elif. Lastly,
# I practiced creating functions that included math operations, if/else statements, and type casting.
# The difficulties I had were with improving the multiplying calculator function in Task 3. I didn't know how to
# use the elif keyword in if/else statement until the next lesson.
# But when I learned how, I figured out that I had to use it to test the multiple conditions (opertor is /, *,
# or Invalid) and display the result if the operator is not invalid.
# [ This code displays an string containing a math operation followed by the results of the operation.
# Like in regular math, order of operations is followed. ] review and run example
print("3 + 5 =",3 + 5)
print("3 + 5 - 9 =", 3 + 5 - 9)
print("48/9 =", 48/9)
print("5*5 =", 5*5)
print("(14 - 8)*(19/4) =", (14 - 8)*(19/4))
# [ In this code, the function million_maker() is defined. It asks the user for input on a number and then it
# makes it a million by multiplying it by 10000000. The function is called an the result is displayed.]
# review and run example - 'million_maker'
def million_maker():
make_big = input("enter a non-decimal number you wish were bigger: ")
return int(make_big)*1000000
print("Now you have", million_maker())
# This code displays the result of subtracting 15 from 43.
print(43-15)
# This code displays the result of multiplying 15 and 43.
print(15*43)
# This code displays the result of dividing 156 by 12. The answer is always a float.
print(156/12)
# This code displays the result of dividing 21 by 0.5.
print(21/0.5)
# This code displays the result of adding 111 and 84, and then substracting 45.
print(111+84-45)
# This code displays the result of adding 21 +4, and then multiplying that by 4. The parentheses are resolved
# first and then the multiplication.
print((21+4)*4)
def multiply():
one_num = int(input("enter 1 whole number: "))
two_num = int(input("enter another whole number you want to multiply by the previous one: "))
calc = one_num * two_num
display = print(one_num,"*",two_num,"=",str(calc))
return display
multiply()
# This program asks the user to enter 2 whole numbers so that they can be either multiplied or divided. Then, the
# if/else statement contains the return value that will display depending on the statement that turns out to be
# true. The default operator is multiplication, and it's used if no operator is specified.
def multiply(operator= "*"):
print("This a calculator for multiplication and division")
one_num = int(input("enter first whole number: "))
two_num = int(input("enter second whole number: "))
if operator == "/":
return one_num / two_num
elif operator == "*":
return one_num * two_num
else:
return "Invalid Operator"
multiply("/")
# [ This code displayed a syntax error because the elif statement was missing a colon at the end.
# To fix this, I added a colon at the end.] Review, run, fix
student_name = input("enter name: ").capitalize()
if student_name.startswith("F"):
print(student_name,"Congratulations, names starting with 'F' get to go first today!")
elif student_name.startswith("G"):
print(student_name,"Congratulations, names starting with 'G' get to go second today!")
else:
print(student_name, "please wait for students with names staring with 'F' and 'G' to go first today.")