Random inputs and loops in python -
from random import randint r x = r(1, 100) y = r(1, 10) def rannum(x,y): if (x==y): m = 2*y else: z = x * y print z rannum(x,y)
i have value of x , y randomly generated , have function has 2 condition. how construct loop meet x==y condition? how know home many times ran loop meet condition. new programming , got stuck point. please suggest/recommend me way achieve result. have made range of smaller there high probability of selecting same number.thankyou
i don't know why doing it, below understand question.
from random import randint r def rannum(x,y): if (x==y): m = 2*y print m else: z = x * y print z count=0 while true: count=count+1 x = r(1, 100) y = r(1, 10) if (x==y): print "x equal y after count=",count rannum(x,y) break
Comments
Post a Comment