Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Exercise 5.1 If you are given three sticks, you may or may not be able to arrange them in a triangle. For example, if

1. Exercise 5.1

If you are given three sticks, you may or may not be able to arrange them in a triangle. For example, if one of the sticks is 12 inches long and the other two are one inch long, you will not be able to get the short sticks to meet in the middle. For any three lengths, there is a simple test to see if it is possible to form a triangle:

If any of the three lengths is greater than the sum of the other two, then you cannot form a triangle. Otherwise, you can. (If the sum of two lengths equals the third, they form what is called a degenerate triangle.)

  1. Write a function named is_triangle that takes three integers as arguments. The function should return True or False to report whether or not the three sticks can make a triangle.

  2. From main(), call the is_triangle function and pass it three integer values representing the length of three sticks. If the returned value of the is_triangle function is True, print Yes to the screen. Otherwise, print No to the screen.

Test Your Function

Two tests appear here for you to use. Use these buttons to test your code:

Should return No

TRY IT (STICK LENGTHS 1, 1, AND 12)

Should return Yes

TRY IT (STICK LENGTHS 12, 16, AND 24)

Submit For Grading

Once you have tested your code, submit it here for grading.

Exercise 5.1

Make sure the response you print to the screen is either Yes or No (the capitalization is important.)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2. Exercise 5.2

A bike share program in Indianapolis allows customers to borrow a bike and charge them based on the length of their ride.

The program offers two memberships: Daily or Annual.

For Daily members, rides cost 1.50 to start + .20/minute.

For Annual members, rides cost 1.00 to start + .15/minute.

  1. Write a function named calculate_fee that takes a string and an integer as arguments and returns the calculated fee with no dollar signs or rounding based on the users membership level.

  2. From main(), call the calculate_fee function and pass both the string and integer values. The function should calculate the fee based on the membership level. Print the returned value of the calculate_fee function to the screen with no dollar signs or rounding (Do not forget the 1.50/1.00 start ride fee!)

Test Your Function

Two tests appear here for you to use. Use these buttons to test your code:

Should return the float 5.5

TRY IT (DAILY MEMBER TAKES A 20 MINUTE TRIP)

Should return the float 3.25

TRY IT (ANNUAL MEMBER TAKES A 15 MINUTE TRIP)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

3. Exercise 5.3

A persons Body Mass Index is a common measure of their fitness (whether we like it or not.)

The BMI calculation in the English system is:

((weight_in_pounds) / (height_in_inches * height_in_inches)) * 703 

BMI Categories:

  • Underweight = <18.5
  • Normal = 18.524.9
  • Overweight = 2529.9
  • Obese = BMI >= 30
  1. Write a function named calculate_bmi that takes two floats as arguments and returns the calculated BMI rounded to 1 decimal place based on the users weight and height.

  2. From main(), call the calculate_bmi function and pass both float values. Use the returned value of the function to determine and print the BMI Category the user falls into.

Printed Values

Your program MUST print exactly one of the following:

  • Underweight
  • Normal
  • Overweight
  • Obese

Capitalization is important!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

18. In Prob. 15, show det(B) det(A) > 0.

Answered: 1 week ago

Question

16. Implement this MPEMP.

Answered: 1 week ago

Question

11. Store this politicalecological data in the data sets directory.

Answered: 1 week ago

Question

13. Place the results of this analysis in the out files directory.

Answered: 1 week ago