Answer to Question #308945 in Python for hari

Question #308945

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


1
Expert's answer
2022-03-10T02:10:17-0500
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='')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS