Question: I need help to finish my python code.. I have started my code.... here is the homework question.. For this assignment you need to write

I need help to finish my python code.. I have started my code.... here is the homework question..

For this assignment you need to write a program that does the following:

1. Ask a person where they want to go on a vacation. Give them choice of at least THREE different locations. Each location should be different price per person

2. Ask how many people are going on a trip

3. For each person, ask for a name and an email address

4. Tell the person how much they owe

5. Store the information on a file

6. Display a report of ALL people who have booked a vacation

You need to include the following:

1. Flowchartmake sure you create the flowchart FIRST!..

2. A text file to store and retrieve the information. Remember, all information is cumulative!

3. Create at least THREE Functions.

4. Use a LIST or a DICTIONARY

5. Use at least one LOCAL and one GLOBAL variable. the GLOBAL variable should be used in at least one function.

6. Create Exception Handling for Both Data Entry and File Handling.

here is my code...

# vacation Planning

# The following program helps to create a travel itinerary

# Import modules

import destinations

def main():

# Show destinations

destinations.print_options()

# Pick destination

choice = destinations.get_choice()

# Get destination info

destination = destinations.get_info(choice)

# How many people are going

people = destinations.people_info(choice)

# Ask name and email of each person

name = self.name

email = self.email

# Determine length of stay

while True:

try:

length_of_stay = int(input("And how many days will you be staying in," destination " ?" ))

# Check for non-positive input

if (length_of_stay < 0):

print("Please enter a positive number of days.")

continue

except ValueError:

print("The value you entered is invalid. Only numerical values are valid.")

else:

break

# Calculate cost

cost = dollar_rate + length_of_stay

# How much they owe

owe = total_amount - paid_amount

# Save itinerary

try:

save_itinerary(destination, length_of_stay, cost)

# Catch file errors

except:

print("Error: the itinerary could not be saved.")

# Print confirmation

else:

print("Your trip to", destination "has been booked!")

def save_itinerary(destination, length_of_stay, cost):

# Itinerary File Name

file_name = "itinerary.txt"

# Create a new file

itinerary_file = open(file_name, "r")

# Write vacation information

file_name.write("Vacation Itinerary")

file_name.write("--------------")

file_name.write("Destination: " + destination)

file_name.write("Length of stay: " + length_of_stay)

file_name.write("Cost: $" + format(cost, ",.2f"))

print("Travel Options")

print("--------------")

print("1. India")

print("2. Mexico")

print("3. London")

print("")

def get_choice():

# Get destination choice

while True:

try:

choice = int(input("Where would you like to go? "))

if (choice < 1) or (choice > 3):

print("Please select a choice between 1 and 3.")

continue

except ValueError:

print("The value you entered is invalid. Only numerical values are valid.")

else:

return choice

def get_info(choice):

# Use numeric choice to look up destination info

# Rates are listed per day

# Choice 1: India at $30/day

if (choice == 1):

return "India", 30

# Choice 2: Mexico at $25/day

elif (choice == 2):

return "Mexico", 25

# Choice 3: London at $60/day

elif (choice == 3):

return "London", 60

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!