Question

In: Computer Science

This Homework would have two python files for a cheap online ticket seller. (You are free...

This Homework would have two python files for a cheap online ticket seller. (You are free to imagine a new scenario and change any part of the question.)

The main purpose of the homework is to use basic concepts. You should try to use basic python elements like variables, if-else, loops, lists, dictionary, tuple, functions in this homework.

***

Price list to calculate the price for various destinations---

  1. New York :

Price For Delta $ 200.00 (Economy), 300.00(Business), 400(First class)

United 220.00 (Economy), 330.00(Business), 410(First class)

Lufthansa 250.00(Economy), 340.00(Business), 410(First class)

American 260.00(Economy), 300.00(Business), 420(First class)

  1. Los Angeles

Price for Delta $ 250.00(Economy), 300.00(Business), 400(First class)

United $270.00 (Economy), 300.00(Business), 400(First class)

Lufthansa $ 290.00, (Economy), 300.00(Business), 400(First class)

American $ 280.00(Economy), 300.00(Business), 400(First class)

  1. Cleveland

Price for Delta $ 350.00(Economy), 410.00(Business), 500.00(First class),

United 360.00(Economy), 4200.00(Business), 510(First class),

Lufthansa 370.00(Economy), 440.00(Business), 530(First class),

American 370.00(Economy), 430.00(Business), 510(First class)

  1. Las Vegas

Price For Delta $ 370.00(Economy), 410.00(Business), 520(First class),

United 380.00(Economy), 430.00(Business), 550(First class),

Lufthansa 390.00(Economy), 460.00(Business), 600.00(First class),

American 400.00(Economy), 470.00(Business), 590.00(First class)

For 6.00 AM and 11.00 AM flight, nothing to extra charge but 2.00 PM and & 7.00 flight has a $ 50.00 extra charge to book. However, the 11.00 PM flight has an extra charge of $ 70

***

  1. Utilities – This file will calculate all calculations.
  2. Application- This file will have the main application that imports the other two files and use the def main () function.

Output: Do you Want to buy a ticket?

Enter Option 1 for buy ticket 2 for no:

  1. Start Calculation
  2. Exit

How many people are you going to travel with? (Choose option Maximum 5):

  1. One passenger
  2. Two passengers
  3. Three passengers
  4. Four passengers
  5. Five passengers

Choose your destination from the below options menu:

  1. NEW YORK
  2. LAS ANGELES
  3. CLEVELAND
  4. DALLAS
  5. LAS VEGAS

What airline company do you want to travel with for destination:

Choose an option from the menu:

  1. DELTA
  2. UNITED
  3. LUFTHANSA
  4. AMERICAN

What class do you want to travel to? :

Choose an option from the menu:

  1. FIRST CLASS
  2. BUSINESS CLASS
  3. ECONOMY

What time would you like to travel to a destination? :

Choose an option from the menu:

  1. 6.00 AM
  2. 11.00 AM
  3. 2.00 PM
  4. 7.00 PM
  5. 11.PM

The total price for your travel ticket is:

Enter Option 1 for buy ticket 2 for no:

  1. Start Calculation
  2. Exit

Solutions

Expert Solution

Refer screenshots for correct indentation,without correct indetation programm may show errors/work incorrectly, also make sure that both files are in same folder

utilities.py

# hold ticket classes
TICKET_CLASSES = ('ECONOMY', 'BUSINESS CLASS', 'FIRST CLASS')
# holds destinations
DESTINATIONS = ('NEW YORK','LAS ANGELES', 'CLEVELAND', 'DALLAS','LAS VEGAS')
# holds airline names
AIRLINES = ('DELTA', 'UNITED', 'LUFTHANSA', 'AMERICAN')
# holds times
TIME = ('06.00 AM', '11.00 AM', '02.00 PM', '07.00 PM', '11.00 PM')
# holds the prices
PRICE_TABLE = {
    DESTINATIONS[0]:{
        AIRLINES[0]:{TICKET_CLASSES[0]:200.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:400},
        AIRLINES[1]:{TICKET_CLASSES[0]:220.00, TICKET_CLASSES[1]:330.00, TICKET_CLASSES[2]:410},
        AIRLINES[2]:{TICKET_CLASSES[0]:250.00, TICKET_CLASSES[1]:340.00, TICKET_CLASSES[2]:410},
        AIRLINES[3]:{TICKET_CLASSES[0]:260.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:420}
    },
    DESTINATIONS[1]:{
        AIRLINES[0]:{TICKET_CLASSES[0]:250.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:400},
        AIRLINES[1]:{TICKET_CLASSES[0]:270.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:400},
        AIRLINES[2]:{TICKET_CLASSES[0]:290.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:400},
        AIRLINES[3]:{TICKET_CLASSES[0]:280.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:400}
    },
    DESTINATIONS[2]:{
        AIRLINES[0]:{TICKET_CLASSES[0]:350.00, TICKET_CLASSES[1]:410.00, TICKET_CLASSES[2]:500},
        AIRLINES[1]:{TICKET_CLASSES[0]:360.00, TICKET_CLASSES[1]:420.00, TICKET_CLASSES[2]:510},
        AIRLINES[2]:{TICKET_CLASSES[0]:370.00, TICKET_CLASSES[1]:440.00, TICKET_CLASSES[2]:530},
        AIRLINES[3]:{TICKET_CLASSES[0]:3700.00, TICKET_CLASSES[1]:430.00, TICKET_CLASSES[2]:510}
    },
    DESTINATIONS[3]:{
        AIRLINES[0]:{TICKET_CLASSES[0]:200.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:400},
        AIRLINES[1]:{TICKET_CLASSES[0]:220.00, TICKET_CLASSES[1]:330.00, TICKET_CLASSES[2]:410},
        AIRLINES[2]:{TICKET_CLASSES[0]:250.00, TICKET_CLASSES[1]:340.00, TICKET_CLASSES[2]:410},
        AIRLINES[3]:{TICKET_CLASSES[0]:260.00, TICKET_CLASSES[1]:300.00, TICKET_CLASSES[2]:420}
    },
    DESTINATIONS[4]:{
        AIRLINES[0]:{TICKET_CLASSES[0]:370.00, TICKET_CLASSES[1]:410.00, TICKET_CLASSES[2]:520},
        AIRLINES[1]:{TICKET_CLASSES[0]:380.00, TICKET_CLASSES[1]:430.00, TICKET_CLASSES[2]:550},
        AIRLINES[2]:{TICKET_CLASSES[0]:390.00, TICKET_CLASSES[1]:460.00, TICKET_CLASSES[2]:600},
        AIRLINES[3]:{TICKET_CLASSES[0]:400.00, TICKET_CLASSES[1]:470.00, TICKET_CLASSES[2]:590}
    }
}
# for getting extracharge if any
def getExtraCharge(time):
    if time in [TIME[0], TIME[1]]:
        return 0
    elif time in [TIME[2], TIME[3]]:
        return 50.00
    elif time in[TIME[4]]:
        return 70.00
        
# calculates the price
def calculatePrice(people, destination, airline, ticketClass, time):
    return people * (PRICE_TABLE[DESTINATIONS[destination-1]][AIRLINES[airline-1]][TICKET_CLASSES[ticketClass-1]] + getExtraCharge(TIME[time-1]))


screenshot:

application.py

import utilities 

def main():
    # checks if user wants to buy
    print('Do you Want to buy a ticket?')
    option = input('Enter Option 1 for buy ticket 2 for no: ')
    # if yes then continue
    if option == '1':
        # reads passenger count
        print('''

        Options
        --------
        1) One passenger
        2) Two passengers
        3) Three passengers
        4) Four passengers
        5) Five passengers

        ''')
        people = int(input('How many people are you going to travel with? (Choose option 1-5): '))

        # reads destination
        print('''

        Options
        --------
        1) NEW YORK
        2) LAS ANGELES
        3) CLEVELAND
        4) DALLAS
        5) LAS VEGAS

        ''')
        destination = int(input('Choose your destination from the options menu(1-5): '))

        # reads airline name
        print('''

        Options
        --------
        1) DELTA
        2) UNITED
        3) LUFTHANSA
        4) AMERICAN

        ''')
        airline = int(input('What airline company do you want to travel with for destination:\nChoose an option from the menu(1-4):'))

        # reads ticket class
        print('''

        Options
        --------
        1) FIRST CLASS
        2) BUSINESS CLASS
        3) ECONOMY

        ''')
        ticketClass = int(input('What class do you want to travel to? :\nChoose an option from the menu(1-3):'))

        # reads time
        print('''

        Options
        --------
        1) 06.00 AM
        2) 11.00 AM
        3) 02.00 PM
        4) 07.00 PM
        5) 11.00 PM

        ''')        
        time = int(input('What time would you like to travel to a destination? :\nChoose an option from the menu(1-5):'))

        # prints the price
        print('The total price for your travel ticket is: ', utilities.calculatePrice(people, destination, airline, ticketClass, time),'$')

        # confirm if user wants to buys
        buy = input('Enter Option 1 for buy ticket 2 for no: ')

        if buy == '1':
            print('Thank You for flying with us, Have a Nice Day!')
        else:
            print('Thank You Have a Nice Day!')

# running main if it run as a script
if __name__ == '__main__':
    main()

screenshot:

output:

PS: If you have any problems/doubts please comment below.Thank You.


Related Solutions

Really Cheap Used Computers, Inc. is an online seller of old school computers. The organization’s e-commerce...
Really Cheap Used Computers, Inc. is an online seller of old school computers. The organization’s e-commerce Web site runs on a Linux server. The server is located at the organization’s local office in Boston, Massachusetts. The company has experienced tremendous growth and has hired you as the new security analyst. You access the server and find that there are no layers of security other than the passwords set for user accounts. Discuss at least three layers of access control that...
Python This week you will write a program in Python that mimics an online shopping cart...
Python This week you will write a program in Python that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers...
In this task, you will create a Python script in which you will practice reading files...
In this task, you will create a Python script in which you will practice reading files in Python and writing them to a new output file. Construct a text file called Py4_Task3_input.txt that has the following lines: 4 Sandwiches 04 July 2020 Pasta 31 October 2014 Hot Dogs 15 November 2005 Tacos 25 December 1986 The first line of the file represents the number of lines in the data file. Write a loop that reads in each additional line (one...
a python function that reads two text files and merges in to one Linked List, be...
a python function that reads two text files and merges in to one Linked List, be able to print each Item in the new single Linked List class Node(object): item = -1 next = None def __init__(self, item, next): self.item = item self.next = next ================================ textfile! 979 2744 5409 1364 4948 4994 5089 703 1994 4637 2228 4004 1088 2812 170 5179 2614 238 4523 4849 3592 3258 1951 3440 3977 1247 4076 1824 4759 4855 5430 347 974...
HOMEWORK PROJECT #1 – SHOPPING CART Part I. Create two files to submit: ItemToPurchase.java – Class...
HOMEWORK PROJECT #1 – SHOPPING CART Part I. Create two files to submit: ItemToPurchase.java – Class Definition ShoppingCartPrinter.java – Contains main() method Build the ItemToPurchase class with the following specifications: Specifications Description ItemToPurchase(itemName) itemName – The name will be a String datatype and Initialized in default constructor to “none”. ItemToPurchase(itemPrice) itemPrice – The price will be integer datatype and Initialized in default constructor to 0. ItemToPurchase(itemQuantity) itemQuantity – The quantity will be integer datatype Initialized in default constructor to 0....
Assignment Requirements Write a python application that consists of two .py files. One file is a...
Assignment Requirements Write a python application that consists of two .py files. One file is a module that contains functions used by the main program. NOTE: Please name your module file: asgn4_module.py The first function that is defined in the module is named is_field_blank and it receives a string and checks to see whether or not it is blank. If so, it returns True, if not it return false. The second function that is defined in the module is named...
14 randomly chosen students have each won a free ticket to play a game of chance....
14 randomly chosen students have each won a free ticket to play a game of chance. In this game a wheel is spun that has been equally divided among 20 values, and when the wheel stops spinning a pointer will have selected one of the 20 values randomly (think Wheel-of-Fortune style). So therefore we will assume that each of the 20 outcomes is equally likely. Before spinning, the player chooses which value they think it will stop on. If it...
1. Share your experience buying airline ticket ONLINE. Are you satisfied with services provided by the...
1. Share your experience buying airline ticket ONLINE. Are you satisfied with services provided by the airline? ( price, security of the website, payment failure, additional charges, etc.. ) 2. Give some suggestions for improvement.
Homework 3 Loop and Function (PYTHON) You are asked to develop a compensation calculator application for...
Homework 3 Loop and Function (PYTHON) You are asked to develop a compensation calculator application for a department store. At the department store, the compensation of sales staff consists of a base salary and a commission. The base salary is $5,000, and the commission rate is tiered based on sales amount as following: Sales AmountCommission Rate $0.01 – $5,000 8% $5,000.01 – $10,000 10% $10,000.01 and above12% For example, if the sales amount is $12,000, the commission is calculated as...
in python programming language, please include the proper identation This homework will allow you to demonstrate...
in python programming language, please include the proper identation This homework will allow you to demonstrate understanding and engagement with the following topics: graph representations object oriented programming graph processing,such as finding shortest paths and finding tree traversals Your task is to implement a Graph class. The edges in the graph are undirected, but you must implement an Edge class. In addition, you will have a Graph class, and a Node class. You can choose to implement graphs with any...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT