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(): 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" 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(): 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 show_by_rating(movies_list): #initialize the list movies_to_send = [["","",0]] # remove the initial element movies_to_send.pop() count = 0 rating = validation.get_float("What is the lowest rated movie you want to see? ", 10) for movie in movies_list: if int(movie[2]) >= rating: movies_to_send.append(movie) count += 1 if len(movies_to_send) > 0: print(str(len(movies_to_send)) + " movies found with a rating of at least " + str(rating)) print_movie_list(movies_to_send) else: print("There are no movies in the list with a rating of at least " + str(rating))
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 add_movie_to_list(movies_list, mode): if DEBUG: print("From add_movie_to_list(), mode is: " + mode) movie_name = input("Name: ") if movie_name == "": movie = "Silent Movie" movie_name = movie_name.title()#make title case so the initial char is capitol movie_name = movie_name[0:20]#limit to 20 chars movie_genre = input("Genre: ") if movie_genre == "": movie_genre = "Other, non-specific" movie_genre = movie_genre.title() movie_genre = movie_genre[0:20]#limit to 20 chars movie_rating = validation.get_float("Rating: ", 10) movie = [str(movie_name), str(movie_genre), movie_rating] movies_list.append(movie) if mode != "txt": replace_movies_in_file(movies_list, mode)#write entire list else: save_movie_to_file(movie)#append the movie print("\"" + str(movie) + "\" has been added to the list.")
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!")
def main(): myTimer = timer.begin_timer() stringer.show_welcome(NAME) should_Exit = False while not should_Exit: new_invoice_total = invoice_total = discount_percent = discount_amount = 0 customer_type = "unknown_type" # get customer_type from the user display_customer_types() customer_type = input("Enter customer type (r/w):\t") order_total = Decimal(val.get_float("Enter order total:\t\t", 100000)) order_total = order_total.quantize(Decimal("1.00"), ROUND_HALF_UP) # get invoice date invoice_date = get_invoice_date() current_date, due_date, days_overdue = calculate_due_date(invoice_date) # determine discount for retail customer if customer_type.lower() == "r": customer_type = "Retail" if order_total > 0 and order_total < 100: discount_percent = Decimal("0") elif order_total >= 100 and order_total < 250: discount_percent = Decimal(".1") elif order_total >= 250 and order_total < 500: discount_percent = Decimal(".2") elif order_total >= 500: discount_percent = Decimal(".25") # determine discount for wholesale customer elif customer_type.lower() == "w": customer_type = "Wholesale" if order_total > 0 and order_total < 500: discount_percent = Decimal(".4") elif order_total >= 500: discount_percent = Decimal(".5") # customer is neither wholesale nor retail so discount_percent at zero else: customer_type = "Unknown" # calculate discount and new invoice total discount = order_total * discount_percent discount = discount.quantize(Decimal("1.00"), ROUND_HALF_UP) subtotal = order_total - discount tax_percent = Decimal(".05") sales_tax = subtotal * tax_percent sales_tax = sales_tax.quantize(Decimal("1.00"), ROUND_HALF_UP) invoice_total = subtotal + sales_tax # display results # determine the region for the money result = lc.setlocale(lc.LC_ALL, "") if result == "C": lc.setlocale(lc.LC_ALL, "en_US") line = "{:20} {:>10}" print() print("Customer Type: {:10}".format(customer_type)) print( line.format("Order total:", lc.currency(order_total, grouping=True))) print(line.format("Discount:", lc.currency(discount, grouping=True))) print(line.format("Subtotal:", lc.currency(subtotal, grouping=True))) print(line.format("Sales tax:", lc.currency(sales_tax, grouping=True))) print( line.format("Invoice total:", lc.currency(invoice_total, grouping=True))) print() show_due_date(invoice_date, current_date, due_date, days_overdue) print() choice = input("Try again? (y/n): ") if choice.lower() != "y": should_Exit = True # end while loop timer.stop_timer(myTimer) print("Bye!")