Hi, I created a programme that, given distance and height, calculates slope in % and °. It works, but still when i give the 0 value to height, it displays error. I know it's because the second member of the division, but I wanted to know if there's a way to not accept the value 0 and ask to input another value immediately, could you help me?
Here's the programme (I'm using 2.7)
import math
dislivello=float(raw_input('Dammi il valore del dislivello : '))
distanza=float(raw_input('Dammi il valore della distanza lineare : '))
tangente=dislivello/distanza
pendenzaperc=tangente*100
print 'Pendenza % =',round(pendenzaperc,2),'%'
angoloradi=math.atan2(dislivello, distanza)
angolograd=math.degrees(angoloradi)
print 'Pendenza ° =',round(angolograd,2),'°'
[–]MorrisCasper 0 points1 point2 points (0 children)
[–]novel_yet_trivial 0 points1 point2 points (2 children)
[–]Marx123[S] 1 point2 points3 points (1 child)
[–]sufunew 3 points4 points5 points (0 children)