Python Variable Division -
i've been making python program suppose counts how many seconds takes python 2 make 100 cycles, , i've decided @ end convert hz. requires me change second count 1, i've decided easiest dividing itself. note time equates end - start:
time / time pretty simple. problem is, doesn't seem work: time variable remains same. i've tried using 2 slashes, putting 'float' in front , surrounding 2 variables, , have future import division in, none seem work. suggestions?
thanks, oisin
note: time variable not integer, , i'd rather not have truncated. if solution, tell me anyway, i'm thankful help.
you need time , define time. work:
time = 1 print time/time #output 1 if have statement variables aren't defined , don't use in someway, nothing happen. division can performed / long don it.
time/time #nothing time/time + 1 #nothing var = time/time #var becomes result print time/time #prints result also, don't name variable time python has time module avoid confusion. if time equal 1, result 1. try changing equation else x/x 1. try else 1/time suggested in comments.
Comments
Post a Comment