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

+4 votes

Best answer

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.

+4 votes

with a print statement inside the for loop.

for example,

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

would print

```
1
2
3
4
5
```

+4 votes

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)
print(radius, ' ', volume, sep="")
```

Hope this helps!

+4 votes

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.