Earthquake python program. shreya is learing about earthquakes and stumbles accroess an interesting fact: the magnitude of on earthquake is a logarithmic scale of the energy realeased by the earthquake. it is known that each time the magnitude increases by 1, the amount of energy ets multiplied by 32. your tas is to help shreya by determining, how many times is the amount of energy of a magnitude a earthquake compared to that of a magnitude B earthquake?
I/p : a=6 & b=4, 6 is 2 greater than 4, so a magnitude 6 earthquake has 32*32=1024 times as much energy as a magnitude 4 earthquake has. so, the output is 1024
Input : 6 4
O/p: 1024
I/p: 5 5
O/p: 1
line = input()
words = line.split()
a = int(words[0])
b = int(words[1])
times = 1
if a >= b:
for i in range(a-b):
times = times * 32
print(times)
else:
for i in range(b-a):
times = times * 32
print('1/', times, sep='')
Comments
Leave a comment