23rd Aug 2023, 1:37 PM
P A Arrchith Iyer
P A Arrchith Iyer - avatar
4 Answers
+ 6
Arrchith , 2 suggestions p: (1) the function can be shortened like: def p(m,v): return m*v (2) since the calculation is quite simple, we can do it directly in the output string: weight = int(input()) velocity = int(input()) print(f'weight of {weight} kg and velocity of {velocity} m/s give us the momentum of {weight * velocity} kg.m/s',"\n\nCode by Arrchith")
24th Aug 2023, 6:00 PM
Lothar
Lothar - avatar
+ 5
See this, maybe it's helpful to you https://code.sololearn.com/cX0z5vBtCYTi/?ref=app
23rd Aug 2023, 1:56 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 5
# A small addition to Sakshi answer can be helpful for readability of a code: # Modified Code: def p(m,v): momentum = m*v return momentum bulk = int(input()) velocity = int(input()) momentum = p(bulk,velocity) print(f'Bulk of {bulk} kg and velocity of {velocity} m/s give the momentum of {momentum} kg.m/s',"\n\nCode by Arrchith")
23rd Aug 2023, 3:38 PM
JaScript
JaScript - avatar
+ 3
Thank you
23rd Aug 2023, 4:02 PM
P A Arrchith Iyer
P A Arrchith Iyer - avatar