I have a small piece of code, to understand how to be used in other sections of the code The values have to be returned. In the following I just want to return variable z, or value snooze. But it does not work. Can someone please help me understand why this will not work? Import time Deep sleep (Representative, Snooze): T = [] X in range (representative): X = time.time () time.sleep (snooze) y = time.time ( ) Z = y - x t.append (z) Print 'difference =', z * 1000 print 'total:', (zodiac (t) / representative) * 1000 returns z sleep (10, 0.001) print z # not like this.
If I print Snooze, then it also messes up why?
Your function returns the value of I used a different name to make it clear that < Code> slept is a different variable. z your local variable is sleep () Function; It is not visible outside of that function.
z ; Think of this:
slept = sleep (10, 0.001) Print slip
No comments:
Post a Comment