Write a program that has 5 functions name your functions


The program is in Python

Write a program that has 5 functions. Name your functions based on its functionality. Avoid naming your function, funtion1, fucntion2, etc. For example, a function that converts inches to centimeters may be named inchTocm.

Function 1: This function accepts a string of characters and displays it 5 times on the screen. In your main function, you will show its usage.

Function 2: This function asks for 2 whole numbers such as 10 and 21 and display all of the odd numbers between the 2 parameters. In this case, the function will display 11 13 15 17 19 and 21. Calculate and return the total of the odd numbers. Call this function in the main function to show how it could be used.

Function 3: This function accepts as its parameter any number. The function will display the number followed by *****, followed by the number squared, followed by &&&&&, and followed by the number cubed. For example, if the parameter value is 5, the function will display 5***25&&&125. In your main function, call this function with as many numbers at the user wishes to enter. So, use a sentinel value. Note that the loop as OUTSIDE of the function.

Function 4: This function accepts the number of items to be entered by the user, asks for the indicated number of items and it calculates and returns the total of the numbers. Note that the loop that calculates the total is inside this function. If the value of the total happens to be more than 10 return -1. Otherwise, return the calculated total.

Function 5: (Don't let the MATH bother you! You just have to convert the formula into a program statement. This function calculates and returns the distance an object falls due to gravity in a specific time period. The formula is:

Distance = ½ * gravity * time2

The function accepts as parameters the value for gravity and the value for time the object has been falling. The function returns the value of distance. In your main function, use a loop to ask the user for a set of values for gravity and time and display the value for distance. For example, if the value of gravity is 9.8 and time is 10, distance will be 98.

Make sure to write code to show the usage of all of the functions you have created.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write a program that has 5 functions name your functions
Reference No:- TGS02511827

Now Priced at $25 (50% Discount)

Recommended (95%)

Rated (4.7/5)