def main(): print("~~~~Welcome to pycalculator~~~~") n = bootcamp.get_int("what is n?") use_degrees = False while True: choice = input("use degrees (y/n)? ") if choice == "y": use_degrees = True break elif choice == "n": use_degrees = False break calculator = Calculator(n, use_degrees) while True: operation = input( "what operation? (type help for help, quit to exit) ") if operation == "quit": # quit program return if operation == "help": print("Avaliable Commands: ") for op in calculator.valid_operations: print(op) elif operation in calculator.valid_operations: if operation == "add": args = get_input(2) print(calculator.add( *args)) # same as print(calculator.add(args[0], args[1])) if operation == "add_n": args = get_input(1) print(calculator.add_n(*args)) if operation == "subtract": args = get_input(2) print(calculator.subtract(*args)) if operation == "multiply": args = get_input(2) print(calculator.multiply(*args)) if operation == "divide": args = get_input(2) print(calculator.multiply(*args)) if operation == "cos": args = get_input(1) print(calculator.cos(*args)) if operation == "sin": args = get_input(1) print(calculator.sin(*args)) else: print("INVALID INPUT")
import bootcamp minutes = -1 while True: minutes = bootcamp.get_int("Minutes?") if minutes >= 0: break else: print("invalid minutes, try again") bottles = minutes * 12 print("That shower was equivalent to %i bottles of water" % (bottles))
import bootcamp minutes = bootcamp.get_int("How many minutes was the shower?") bottles = minutes * 12 print("That shower was equivalent to %i bottles of water" % (bottles))
def main(): num = -1 # restrict to max of 3 digits while num < 0 or num > 30: num = bootcamp.get_int("n?") table(num)
import bootcamp x = bootcamp.get_int("what should x be?") print("your number was %i" % (x))
def get_input(num_inputs): inputs = [] for i in range(num_inputs): inputs.append(bootcamp.get_int("value?")) return inputs
import bootcamp while True: height = bootcamp.get_int("height? ") if height > 0 and height <= 23: break for i in range(height): for space in range(height - i - 1): print(" ", end="") for hashes in range(2 + i): print("#", end="") print("\n", end="")