Write a program that asks the user to enter two integer numbers X and Y. The program halves each number between X and Y then prints the values on the screen. For example: If X=5 and Y=7, the program prints the following values 5/2=2.5, 6/2=3.0 and 7/2=3.5 Sample run 1: Enter X and Y: 5 7 2.5 3 3.5 Sample run 2: Enter X and Y: 15 10 5.0 5.5 6.0 6.5 7.0 7.5

Respuesta :

Answer:

`I wrote a quick script in Python, to get you started a little basic and doesn't cover much but it works

Explanation:

starting off x = input(...) and y = input(...) is simply grabbing the input from the users then I make a base array vals defined like:

vals = []

to store the calculated results

rx = int(x) and ry = int(y), are simply converting the x, y which are strings into a int type, so I can use them on this line:

for i in range(rx, (ry + 1)):

I added the + 1 to ry because the range ends at the number before Y, example:

for i in range(5, 8):

 print(i) -> 5,6,7

with all of that I simply ran an iteration for loop and calculated and store the results into vals presented here:

vals.append(i / 2)

If there's any confusion leave a comment I'll try my best to help out

Ver imagen bigbrainstone
ACCESS MORE