Python 3.* HALP PLEASE!

Let me preface this by saying not only have I never used Python before - I have never programmed ANYTHING before.

I have to write a python (script/program?) in python 3.*
The program must be able to have a user input 3 different unsurance company names, and their associated monthly costs.
Then the program must calculate the annual cost, as paying annual instead of monthly saves 3%
Then it must list the companys from most to least expensive, and show how much is saved by paying annualy

NOTE: Only allowed to use sequence. Not allowed to use selection or repletion

So far I have this

print ("This tool will compare insurance premiums for three companies")
name_A = (input("Please type the name of the first company, then press enter:"))
annual_A = int(input("Please enter the cost of the annual payment:"))
name_B = (input("Please type the name of the second company, then press enter:"))
annual_B = int(input("Please enter the cost of the annual payment:"))
name_C = (input("Please type the name of the third company, then press enter:"))
annual_C = int(input("Please enter the cost of the annual payment:"))
monthly_A = annual_A / 12 * 1.03
monthly_B = annual_B / 12 * 1.03
monthly_C = annual_C / 12 * 1.03
saving_A = annual_A * 0.03
saving_B = annual_B * 0.03
saving_C = annual_C * 0.03
print ("The monthly costs ordered most to least expensive are")

How do I A) make a list, and B) order it by value?

what's this for? work? school? fun?

something in me doubts that if they have never programmed anything before, that they would start out with sorting algorithms, before they even knew how to make a list.

1 Like

I would start with this.
1. https://docs.python.org/3/tutorial/datastructures.html
2. https://docs.python.org/3/howto/sorting.html

2 Likes

Its for University

What class? This is your assignment?

Yep - Introduction to Programming

Here’s a solution demonstrating some Python language features

def insurance_input()
  """Returns insurance company name and annual cost"
  name = input("Please type the name of the first company, then press enter:")
  annual_cost = int(input("Please enter the cost of the annual payment:"))
  return name, annual_cost

all_data = [insurance_input() for _ in range(3)].sort(
    key=lambda name, cost: -cost)

print ("The monthly costs ordered most to least expensive are:")
print("\n".join("%s\t%s" % ii for ii in all_data))

Edit: Sigh … sorry for the necro