Question

In: Computer Science

(Python language) Going out with the gang? You are planning an outing with some friends and...

(Python language)

Going out with the gang?

You are planning an outing with some friends and need to calculate the total price of the tickets. A regular ticket usuallycosts$3.99 and a student ticket costs only $2.99. If the total number of tickets being ordered (including both students andregular tickets) is at least 10, then a 10% discount is applied to the order. However, if it is a holiday, then the at-least-tengroup discount is only 5% (not 10%).Write a functiontotalticketprice: given three parameters (the number of regular tickets, the number of studenttickets, and whether or not it is a holiday), compute and return the total. Be sure to define and use constants forREGULARTICKETPRICEandSTUDENTTICKETPRICE. We’ll check for this.

Is it time for tea?

Your friend lives in London, England in a timezone that is normally 6−hours ahead of Toronto, Canada. But sometimesEngland and Canada switch to daylight savings time on different dates. If Toronto is on daylight savings time and Londonis not, then the time difference is only 5−hours. Conversely, if London is on daylight savings time and Toronto is not, thetime change is 7−hours. Of course, if both are on daylight savings time, the difference is back to the standard 6−hours. Write the functionbritishtimewhose first parameter is a float value representing the time in Toronto as 24-hour time.The next two parameters are booleans indicating whether Toronto and London are on daylight savings time, respectively.Your function should return the time in London as a float.One last complication is that your function should not return a time greater or equal to 24.0 or less than 0.0.Suggestion: at first do not consider this final complication and write test cases where the expected output is already less than24.0(in the same day). Once that is working, add a test case where the time in Toronto is so late at night that London isalready the next morning. Fix the body of your function to work correctly.For the purpose of this lab, afunctiontakes some input (not always) and returns some output (not always). Go back and makesure that none of your functions print anything!Printing is notthe same as returning!

Solutions

Expert Solution


def totalticketprice(no_of_regular_tickets, no_of_student_tickets, is_holiday):
    price_sum = no_of_student_tickets * 2.99 + no_of_regular_tickets * 3.99
    
    discount = 0  #initally discount percentage is 0
    if no_of_regular_tickets+no_of_student_tickets >= 10:
        if is_holiday:
            discount = 5
        else:
            discount = 10
    
    discount = discount/100 * price_sum #calculate total discount on price_sum from discount percentage
    price_sum = price_sum - discount
    return price_sum

Above is the python function for question 1 Going out with the gang?

It is well commented for your understanding. It has three parameters : no_of_student_tickets, no_of_regular_tickets, and a boolean variable is_holiday (which is True/1 if it is a holiday otherwise False/0).

Note: As you have not mentioned, it is assumed only the first question is to be answered as per our policy. But If you still help in Q2, please let me know the correct input format for 24 hour time by giving a sample example as it is not clear from the question. Thanks and let me know if you have any doubts in the above solution.


Related Solutions

Provide an example of each type of gang model. - Group of friends - Spontaneous Criminal...
Provide an example of each type of gang model. - Group of friends - Spontaneous Criminal Activity Group - Purposive Gang - Youth Street Gang - Structured Criminal Organization
Python Language Only! Python Language Only! Python Language Only! Python 3 is used. When doing this...
Python Language Only! Python Language Only! Python Language Only! Python 3 is used. When doing this try to use a level one skill python, like as if you just learned this don't use anything advanced if you can please. If not then do it as you can. Assume you have a file on your disk named floatnumbers.txt containing float numbers. Write a Python code that reads all the numbers in the file and display their average. Your code must handle...
How does pathways theory explain women’s gang involvement? What are some pathways to gang involvement for...
How does pathways theory explain women’s gang involvement? What are some pathways to gang involvement for young women? What are the ways out of the gang for young women?
In a simple experiment, you are going out there to the duck pond to seine out...
In a simple experiment, you are going out there to the duck pond to seine out one redbreast sunfish at random, determine its sex, and put it back in the pond and then, after 30 minutes, repeat this process. Assuming that the sex ratio for redbreast in the pond is 1:1, develop and plot the pmf of the random variable X, defined as the number of females in the two fish observed. Is the distribution of X symmetric or asymmetric?...
Explain this python program as if you were going to present it to a class in...
Explain this python program as if you were going to present it to a class in a power point presentation. How would you explain it? I am having a hard time with this. I have my outputs and code displayed throughout 9 slides. #Guess My Number Program # Python Code is modified to discard duplicate guesses by the computer import random #function for getting the user input on what they want to do. def menu(): #print the options print("\n\n1. You...
Python language!!!!! №1 The translation from the Berland language into the Birland language is not an...
Python language!!!!! №1 The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if...
In python language do thee following: Some password scheme is designed such that the password must...
In python language do thee following: Some password scheme is designed such that the password must start with a special symbol in “$” “@” or “!” followed by four letters that could be in a..z followed by a similar special symbol followed by three letters in A..Z followed by a single digit. Write a program that takes from the user a string, and verifies whether the string abides by this password scheme. Do this once using regular expressions. Another time...
A woman is going to a friends house to discuss opening a business
 A woman is going to a friends house to discuss opening a business. At 11am she starts from rest and accelerates at a constant 2.5m/s2 for 9s to get to cruising speed. She drives for 15 minutes at this constant speed before she enters city traffic. She stops at her friends house which is straight lined from hers 27km. She arrives at 12:15. Time interval is 11 to 12:15. What is her initial velocity? What is her final velocity ?...
You and a group of friends are planning to visit a theme park, which charges $60...
You and a group of friends are planning to visit a theme park, which charges $60 for admission, $80 for a two-day pass, and $90 for a three-day pass. Your friends are interested in spending a lot of time there, but they’re worried about paying a lot of money. You explain the concept of marginal cost, which helps them see that the additional day is a good value. 1. The average cost per day of a three-day pass is   $   per person....
Language: Java Create a TryIt.java program with a main method. You are going to use this...
Language: Java Create a TryIt.java program with a main method. You are going to use this program to demonstrate some things about how Java works. Make your methods here private, because they are not intended to be called from outside the program. For each test below, make sure that you print to the console: 1) What is being tested 2) The desired output 3) The actual output Question to be answered: Should you use == or the String method equals...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT