# Routine Practice 4 Question 5

How would you get your loop statement to repeat the radius and volume inputted by the user?

You can set your input variable equal to the radius and then put your variable into the range+1, but then when you do you equation you want to use your "for" variable so that way the inputted radius will be supplemented into the loop. i.e
for i in range (1, rad+1):
then your equation in terms of i goes here.

selected

with a print statement inside the for loop.

for example,

``````for i in range(5)
print(i)
``````

would print

``````1
2
3
4
5
``````

There is a hint mentioned in the description that there are 7 spaces between the radius number and the volume.

So you can use the loop to print the output of radius and volume like

``````for i in range(1,variable+1):
print('word')
``````

If you apply that loop form into question 5, you just create print() with 7 spaces (' ') between the radius variable and volume variable and with sep="" if there are any comma:
ex:

``````for radius in range(1, inputrad+1)
``````

Hope this helps!

Suppose that n is the input variable.

First, find the range for the loop. As stated in the problem, you will have to print the radius and volume n times. Hence, you will get the range (1,n+1).
example:
for r in range (1,n+1):

Note: The variable r is equal to the radius. Therefore, if you want to print the radius, print r.

Second, find the calculation for the volume and put it in the loop.

The final step is the print statement, make sure to put it in the loop.

edited by
+1 vote

Let us consider a is your input variable. So, for the loop just add -

for i in range(1,a+1):

`````` print(a)
``````

And it would give you the output -
1
2
3
4
5

+1 vote

Hi,
I know everyone answered the same answer but in simple words it's just:

For hi in range(1,Yourvariable+1):

``````print(radius, '           ', volume, sep="")
``````

which would repeat the variables because it is in the for loop!!!

I know its the same answer but gotta get some points!!!!