write python program 2

  1. You are asked to create a conversion table for a store manager who needs to convert from yards to inches. The range of the conversion is based on the manager’s need. Write a program to ask the user to enter the lower bound and the upper bound (both are positive integers) for the conversion. The program produces the table in accordance with the user’s input with an increment of 1 yard. For example, the user enters 3 for the lower bound and 10 for the upper bound, the program produces the following table.

Yards

Inches

3

108

4

144

5

180

10

360

2. Write a program to ask the user to enter a lower bound value and an upper bound value. The program prints the integers that are multiple of 7 in the range between the lower bound value and the upper bound value inclusive. It also displays the number of integers which are multiples of 7 in the range. Below is a sample run

Enter the lower bound: 20

Enter the upper bound: 70

The multiples of 7 in the range are

21

28

35

42

49

56

63

70

The total number of multiples of 7 in the range is 8

3. Johnny needs a program to help him graph the function: . Write a program to evaluate the function starting at x = -5.00 and ending at x = 8.00 with an increment of 1.00. The program uses these x values to evaluate the function. The output of the program looks like:

X

Y

-5.00

102.00

-4.00

70.00

-3.00

44.00

6.00

80.00

7.00

114.00

8.00

154.00

4. Write a program that reads in 20 characters in sequence. The program tallies and prints the number of times letters, digit characters or other characters entered by the users. For instance, if the characters entered by the users were
About13:24:43p.m.???, then the output of the program would be:

Number of letters: 7

Number of digit characters: 6

Other characters: 7

Hint: You may enter all 20 characters at the same time (i.e. pressing Enter after entering all 20 characters on the same line). However, the program needs to read in one character at a time, one by one. The program processes the characters entered one by one. You need to use three separate counters: one for letter count, one for digit count, and one for other types of characters.

5. Write a function named determineRating which has one parameter rating_score (an integer, in a scale of 1 to 10). The function returns an appropriate rating based on the criteria below:

Rating Score

Rating

7 – 10

‘G’

4 – 6

‘A’

1 – 3

‘P’

6. Write a function named getTime that has three parameters: hours, minutes, and seconds. The function converts and returns the total number of seconds based on the given time. For example, if the values passed to time are 0, 30, and 10, respectively, the function returns the value 18107. Write a function named computeArea to receive three positive real parameters: length1, length2, and length3, representing the sides of a triangle. It calculates and returns the area of the triangle made up by the given three lengths. Listed below is the prototype of this function.

Hint: The area of a triangle with 3 given lengths is calculated using Heron’s formula as follows:

Area = , where s is the half perimeter or half of the sum of the lengths.

8. An auto insurance agency determines insurance premium based on sex and age. Males below age 25 pay the highest premium, $1000. Males 25 or older pay $700. Females below age 21 pay $800, whereas those 21 or older pay $500. Write a function named computePremium that has two parameters: age (an integer) and gender (‘f’ = female, ‘m’ = male).

9. Write a program to read in ages stored in a text file named ages.dat until end of file is reached. It displays the number of ages that are higher than 60 and the sum of the ages that are less than 20.

10. A text file named wages.dat holds records of employees who worked last week. Each record is stored on the same line in the file. Each line consists of number of hours worked (an integer value) and hourly wage (a real value). Write a program stops reading data in from the file when the number of hours worked is -1. Complete each task below in a separate program.

    1. The program displays the number of records processed and the total wages paid to the employees.
    2. The program displays the total number of employees with hourly wage higher than $8.00.
    3. The program displays the average hourly wage of all employees.
    4. The program displays the number of employees who made higher than $300.00 last week.
    5. The program displays the highest wage paid to the employee.

Solution:

15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!