Question: Basic Python Programming 3 test runs for each question Use Control Statements (if and loops) that's it 7. Write a program using while loop with

Basic Python Programming

3 test runs for each question

Use Control Statements (if and loops) that's it

7. Write a program using while loop with validation where user input wholesale prices to calculate retail prices. The markup is 2.5 times. Validation is to check if a value is out of range and display a message to let the user know that the value entered is an error. In this case the wholesale value cannot be less than zero.

Sample Run 1

>>>

Enter the items wholesale cost: -.50

ERROR: the cost cannot be negative

Enter the correct wholesale cost: .50

Retail price is $1.25

Do you have another item?

(Enter y for yes): n

Sample Run 2

Enter the items wholesale cost: .75

Retail price is $1.88

Do you have another item?

(Enter y for yes): Y

Enter the correct wholesale cost: .50

Retail price is $1.25

Do you have another item?

(Enter y for yes): n

8.Write a for loop using range() function to print Barzinger 5 times.

Barzinger

Barzinger

Barzinger

Barzinger

Barzinger

(one test run only for this question)

9.Write a program that uses a for loop to calculate the sum of numbers. The user will specify how many numbers to sum.

Sample Run

>>>

How many numbers do you want to add? 3

Enter number 1 : 25

Enter number 2 : 34

Enter number 3 : 33

The total is 92.0

10.Write a program using for loop to convert speeds from 60kph through 130kph (in 10 kph increments) to mph. The formula: mph = kph * conversion factor where conversion factor is 0.6214. (one test run only for this question)

Sample Run

>>>

KPH MPH

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

60 37.3

70 43.5

80 49.7

90 55.9

100 62.1

110 68.3

120 74.6

130 80.8

8.6.1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!