def main(): choice = "y" monthly_investment = 0 yearly_interest = 0 yearly_interest_rate = 0 years = 0 while choice.lower() == "y": # Getting monthly_investment & yearly_interest_rate from user # "...validation.get_float()", is calling the file validation.py to this section in the def main() monthly_investment, yearly_interest_rate = validation.get_float() # Getting years from user # "...validation.get_int", is calling the file validation.py to this section in the def main() years = validation.get_int() # get and display future value future_value = calculate_future_value(monthly_investment, yearly_interest_rate, years) print() print("Future value:\t\t\t" + str(round(future_value, 2))) print() # see if the user wants to continue choice = input("Continue? (y/n): ") print() print("Bye!")
def main(): myTimer = timer.begin_timer() stringer.show_welcome(NAME) print() # tuple of product objects demonstrating polymorphism products = (Product("Heavy hammer", 12.99, 62), Product("Light nails", 5.06, 0), Movie("Blade Runner", 29.99, 0, 1984), Book("Moby Dick", 19.99, 0, "Herman Melville"), Product("Medium tape", 7.24, 0)) show_products(products) while True: print() try: number = val.get_int("Enter Product number: ", len(products), 0) product = products[number - 1] show_product(product) except Exception as e: print("There was an Error processing your product.", e) break choice = input("View another? (y/n): ").lower() if choice != "y": break # end while loop timer.stop_timer(myTimer) print("Bye!")
def main(): myTimer = timer.begin_timer() stringer.show_welcome(NAME) should_Exit = False yearly_interest_rate = monthly_investment = Decimal("0.00") years = 0 while not should_Exit: print() # get validated input from the user monthly_investment = Decimal(validation.get_float("Enter monthly investment:\t", 1000)) yearly_interest_rate = Decimal(validation.get_float("Enter yearly interest rate:\t", 15)) years = validation.get_int("Enter number of years:\t\t", 50) future_value, total_investment = calculate_future_value(monthly_investment, yearly_interest_rate, years) display_investment_results(monthly_investment, years, total_investment, future_value) if years != 20: choice = input("See results for 20 year investment? (y/n): ") if choice.lower() == "y": # call using default value for years future_value, total_investment = calculate_future_value(monthly_investment, yearly_interest_rate) # call function using named args in alternative order display_investment_results(monthly_investment, totalInv=total_investment, resulting_value=future_value, years=20) choice = input("Try Future Value program again? (y/n): ") if choice.lower() != "y": should_Exit = True # end while loop timer.stop_timer(myTimer) print("Bye!")
def main(): choice = "y" while choice.lower() == "y": # get input from the user monthly_investment = get_number("Enter monthly investment:\t", 0, 1000) yearly_interest_rate = get_number("Enter yearly interest rate:\t", 0, 15) years = get_integer("Enter number of years:\t\t", 0, 50) monthly_investment = v.get_float("Enter monthly investment:\t", 0, 1000) yearly_interest_rate = v.get_float("Enter yearly interest rate:\t", 0, 15) years = v.get_int("Enter number of years:\t\t", 0, 50) # get and display future value future_value = calculate_future_value( monthly_investment, yearly_interest_rate, years) print() print("Future value:\t\t\t" + str(round(future_value, 2))) print() # see if the user wants to continue choice = input("Continue? (y/n): ") print() print("Bye!")
def main(): choice = "y" while choice.lower() == "y": # get input from the user monthly_investment = validation.get_float( "Enter monthly investment:\t", 0, 1000) yearly_interest = validation.get_int("Enter yearly interest rate:\t", 0, 15) years = validation.get_int("Enter number of years:\t", 0, 50) future_value = calculate_future_value(monthly_investment, yearly_interest, years) print("Future value:\t\t\t" + str(round(future_value, 2))) print() choice = input("Continue? (y/n): ") print() print("Bye!")
def my_fib(): num = val.get_int("Enter an integer number less than 25: ", 25) print() try: for i in range(num): print(calculate_fib(i), end=" ") except Exception as e: print("There was an Error processing your number.", e)
def my_factorial(): num = val.get_int("Enter an integer number less than 25: ", 25) print() try: result = calculate_factorial(num) print("The factorial value of " + str(num) + " is: " + str(result)) except Exception as e: print("There was an Error processing your number.", e)
def delete_movie_from_list(movies_list, save_mode): if len(movies_list) == 0: raise ValueError("There are no movies in the list!") else: index = validation.get_int("Movie Index: ", len(movies_list)) #double check theuser's intention to delete the movie choice = input("Are you sure you want to delete the movie (y/n)?") if choice.lower() == "y": movie = movies_list.pop(index-1) replace_movies_in_file(movies_list, save_mode) print(str(movie[0]) + " has been deleted.\n")
def my_towers(): num_disks = val.get_int("Enter an integer number of disks to move (less than 10): ", 10) numCalls = (2 ** num_disks) - 1 print() try: move_disk(num_disks, "A", "B", "C") print() print("All disks moved in " + str(numCalls) + " moves.") except Exception as e: print("There was an Error processing your number.", e)
def main(): monthly_investment, yearly_interest_rate = validation.get_float() years = validation.get_int() # get and display future value future_value = calculate_future_value(monthly_investment, yearly_interest_rate, years) print("Future value:\t\t\t" + str(round(future_value, 2))) print() # see if the user wants to continue choice = input("Continue? (y/n): ") print() print("Bye!")
def main(): myTimer = timer.begin_timer() stringer.show_welcome(NAME) print() while True: print() try: number = val.get_int("Enter number of dice to roll: ", 10, 0) # use validation module to set max 10 dice #create Dice object to hold the dice dice = Dice() for i in range(number): die = Die() dice.addDie(die) #roll dem bones! dice.rollAll() print("YOUR ROLL: ") # use itertor from class Dice for die in dice: print(die.getImage()) print() except Exception as e: print("There was an Error processing your roll.", e) break choice = input("Roll again? (y/n): ").lower() if choice != "y": break # end while loop timer.stop_timer(myTimer) print("Bye!")
def main(): choice = "y" while choice.lower() == "y": # get welcomed print("Welcome to the Future Value Calculator\n") # get input from the user monthly_investment, yearly_interest_rate = validation.get_float() years = validation.get_int() # get and display future value future_value = calculate_future_value(monthly_investment, yearly_interest_rate, years) print("\nFuture value =\t\t\t" + str(round(future_value, 2))) print() # see if the user wants to continue choice = input("Continue? (y/n): ") print() print("Bye!")