# Using loops within an equation for Python and inputting values into QGIS [closed]

I would like to incorporate the use of loops within my Python coding equation. I am looking to find the value for the radius (distance) for multiple earthquakes and their corresponding intensity values. I am getting the magnitude and depth data from the USGS Excel Spreadsheet file. At the moment my code looks like this (see attached) but I would like to remove the Input MMI Intensity Value code and use a loop that runs intensity values from 0 to 12, in 0.5 intervals, into the equation.

``````ml = float(input("Enter Magnitude Value: "))
h = float(input("Enter Depth Value: "))
Iso = float(input("Enter Intensity MMI Value: "))
import math

Io = 1.5 * (ml - math.log(h) + 1.4)
a = (Io - Iso) / (1.8)
d = (10 / 8) * (a)

d = d - 1
if d <= 0:
print("Distance is zero")
else:
d = math.sqrt(h * h + d * d)
``````

Once I have the distance for each individual intensity value, I would like to input these distances into QGIS, along with other Earthquake data, to create an earthquake hazard map that has radii rings of varying intensity around an earthquake point.

Use range. As far as I know you cant use decimal numbers as step (with this range function) so divide by ten:

``````for Iso in [i/10 for i in range(0,125,5)]:
print(Iso)

0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
...
12.0
``````

``````ml = float(input("Enter Magnitude Value: "))
h = float(input("Enter Depth Value: "))
#Iso = float(input("Enter Intensity MMI Value: "))
import math

Io = 1.5 * (ml - math.log(h) + 1.4)

for Iso in [i/10 for i in range(0,125,5)]:
a = (Io - Iso) / (1.8)
d = (10 / 8) * (a)
d = d - 1
if d <= 0:
print("Distance is zero")
else:
d = math.sqrt(h * h + d * d)
Enter Magnitude Value: 3.7

Enter Depth Value: 6.1