Week 8 Lab Monday

Objectives:

Lab Practice

  1. Write a function ticket_cost, that has two parameters, age of the person and the full price of ticket, and finds the final cost of the amusement park ticket for ONE person using the rules below:

    Write a program that calculates the total cost of amusement park tickets for a family of 4 people. The input: full price of the ticket (integer), age of each family member (integer), tax (integer). Output: Total price after all discount and taxes are taken in account. The program uses function ticket_cost

  2. Write a function, gross_margin that accepts two parameters - revenue and cost of goods sold and finds the gross margin expressed as percentage using the following formula gross_margin% = 100*((revenue-cost_of_goods_sold)/revenue)) For more information about gross margin read here

    Write a program that reads revenue and cost of goods sold for TWO companies and the names of the comnaies. The program finds gross margin for each company, and the company with the higher gross margin. The program should print the NAME of the company

  3. For your safety, some attractions at Disney Parks have height requirements. See the table below that list 2 attractions and their height requirements:

    TABLE : Disney Attractions Height Requirements

    Atrraction Name: Height Requirement
    RiverRun : 42 inches or taller
    Autopia : 54 inches or taller

    Write a function can_ride that has two parameters - name of attraction and the height of the park visitor. The function returns True if the person can ride an attraction and False otherwise.

    Write a program that reads attraction name and height for 3 family members and finds who can ride and who cannot. You can add the names of the family members for your input.

  4. Write a function hypotenuse that has two parameters, sides of right triangles, and returns the length of hypotenuse using the following formula: hypotenuse=sqrt(a^2+b^2), where a and b are other sides of right triangle

    Write a program that reads sides of two triangles, finds the length of hypotenuse for each and the triangle with the longest hypotenuse. Use function sqrt from math library. Don't forget to have import math statement in your program. To use function from math library use math.sqrt syntax.

  5. Write a function div_3 that has one parameter, integer number. The function returns True if the parameter is divisible by 3 and False otherwise.

    Write a program that randomly generates 4 integers in range -20 to 20. Print each integer. For each integer, the program uses function div_3 to check divisibility by 3. Bonus: find the total number of integers divisible by 3 out of 4 randomly generated numbers. Use function random library. Add import random to your program. Use function randint(min_range, max_range) with the following syntax: random.randint(-20, 20)