Quiz - 2

Develop the function is_triangle that receives three positive integers a, b, and c. They represent the sides of a triangle. The function should verify that a triangle is formed with the given parameters. If the given parameters form a triangle, the function should return a string indicating its type, i.e., "Equilateral", "Isosceles", or "Escaleno", otherwise, the function should return the string, "Is not triangle".|br| Note: remember that it is not a triangle when the longest side is greater than or equal to the sum of the other two.

Examples:
is_triangle(2, 2, 2) -> "Equilateral"
is_triangle(3, 2, 2) -> "Isosceles"
is_triangle(4, 2, 6) -> "Is not triangle"
is_triangle(2, 1, 8) -> "Is not triangle"

Develop the function is_leap that receives the parameter year which is a positive integer greater than zero and represents a year. The function should verify if the given parameter is a leap year, therefore, it should return True if it is, or False otherwise. A year is a leap year if it is divisible by 400, or also if it is divisible by 4 but not divisible by 100.

Examples:
is_leap(2014) -> False
is_leap(2016) -> True
is_leap(1900) -> False
is_leap(2000) -> True

Juan Pablo the fisherman, is a good man who works every day of the week. At the end of each work day, Juan must report to the state. Every time he brings a weight of fish greater than established by fishing regulations (50 kilograms) he must pay a fine of 4.00 units per additional kilogram. To keep track, he bought a computer to monitor his work income and asked you to make the function called generate_report that receives a list of positive floats weights, which represent the amount that Juan fished each day of the week. The function should return an array of tuples, where each tuple should be a pair of the form (additional, fine), which represent the amount of additional kilograms that Juan fished during a day and the fine he had to pay respectively. If he did not pay a fine, the result will be 0.0 in both cases.

Examples:
generate_report([25.5, 50.5, 60.25, 15, 100, 50, 30.50]) -> [(0.0, 0.0), (0.5, 2.0), (10.25, 41.0), (0.0, 0.0), (50.0, 200.0), (0.0, 0.0), (0.0, 0.0)]

Develop the function mayor_tres that receives three integers a, b and c. The function must return the highest of the three numbers, without using the functions max or min.

Examples:
mayor_tres(5, 2, 3) -> 5
mayor_tres(-5, 0, -2) -> 0

Develop the function mayor_menor_tres that receives three integers a, b and c. The function must return a tuple of the form (mayor, menor) that represent the highest and the lowest of the three numbers, without using the functions max or min.

Examples:
mayor_menor_tres(5, 2, 3) -> (2, 5)
mayor_menor_tres(-5, 0, -2) -> (-2, 0)

An employee of a company receives a monthly gross income calculated by the amount of hours worked multiplied by its value. From this income, the month’s 11% for taxes, 8% for medical insurance, and 5% for payment to the union of workers are deducted. Develop the function calculate_income that receives a float hour_value and an integer ammount_value that represent how much he earns per hour and the amount of hours worked during the month. The function must return a dictionary of the form:

{"gross_income": A, "taxes": B,
"medical_insurance": C, "union_of_workers": E, "net_income": F}.

Where A, B, C, and D represent the amount of money corresponding to each item.

Examples:
calculate_income(15.0, 120) -> {"gross_income": 1800.00, "taxes": 198.00,
"medical_insurance": 144.0, "union_of_workers": 90.0, "net_income": 1368.00}.

The paint sold at your trusted hardware store has a coverage of 1 liter per every 3 square meters and the paint is sold only in cans of 18 liters that cost each one 80.00 units. Develop the function can_paint that receives an amount in square meters of an area to be painted as a positive integer area. The function should return a tuple with the amount of cans of paint that need to be bought to cover the entire area, as well as their total price, that is, using the form (amount_cans, total_price).
Note: only an integer number of cans of paint is sold.

Examples:
can_paint(10) -> (1, 80.00)
can_paint(100) -> (2, 160.00)
can_paint(54) -> (1, 80.00)
can_paint(55) -> (2, 160.00)

You have attempted of activities on this page