"Taking a Vacation" script in real python enviroment // asking user for input in console


#1

`def hotel_cost(days):
return days * 140
def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475
def rental_car_cost(days):

 cost = days * 40

 if days >= 7:
     return cost - 50
 elif days >= 3:
     return cost - 20
 else:
     return cost

def spending_money(money):
return money

def trip_cost(city, days, money):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money(money)

print trip_cost("Los Angeles", 5, 600)
`
i was wondering just exactly how i would use the input() function to ask the user for all of the inputs instead of just editing the print line in a python 3.5.1 environment, I've tried so many different possibilities, and its really bothering me lol


#2

Take input.. convert to the right data types, call your function?
Am I missing something?


#3

I'm just uncertain on WHERE in the script to apply all my input() strings, or which values to convert. My experience in programming all together is very scarce. an example block of code would be awesome, and I couldn't possibly thank whoever enough if you, or someone posted one. I've tried every possibility i could think of.


#4

You could start by just taking input. Then print that out, see if it worked.

Then you do next thing, which is converting.

When that works, send it to your function.

So start from the beginning and at the very least figure out where you're running into trouble. And then use google to solve that trouble.

Right now your question is pretty much "do it for me" and that's not very exciting


#5

ok, your right i was just getting discouraged

I learned a valuable lesson about defining data types

I came, I saw, I concurred!

`days = input('days') # 5
 days = int(days) 
 money = input('money') #5
 city = input ('city') #Tampa

 def plane_ride_cost(city): # 220

     if city == "Charlotte":
         return int(183)
     elif city == "Tampa":
         return int(220)
     elif city == "Pittsburgh":
         return int(222)
     elif city == "Los Angeles":
         return int(475)
 def hotel_cost(days): # 700
     return int(days * 140)
 def rental_car_cost(days): #180 

     cost = days * 40

     if days >= 7:
         return cost - 50
     elif days >= 3:
         return cost - 20
     else:
         return int(cost)
 def spending_money(money): # 5
     return int(money)

 total = spending_money(money) + plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days)

 print (total) #1105`