# a) random Programme ( 0.0<=N<1.0)
import randomy=random.random() #
print("Random values 0.0<=N<1.0 is ",y)
output
Random values 0.0<=N<1.0 is 0.2099061497032172
Random values 0.0<=N<1.0 is 0.7191584678625492
#b) randint(a,b) Programme
import randoma=int(input("Enter the starting number: "))
b=int(input("Enter the ending number: "))
y=random.randint(a,b) # a<=N<=b
print(" Range a<=N<=b "," a= ",a," b= ",b," Random integer is: ",y )
output
Enter the starting number: 5
Enter the ending number: 15
Range a<=N<=b a= 5 b= 15 Random integer is: 12
Enter the starting number: 5
Enter the ending number: 15
Range a<=N<=b a= 5 b= 15 Random integer is: 5
Enter the starting number: 45
Enter the ending number: 75
Range a<=N<=b a= 45 b= 75 Random integer is: 67
#c) randrange(<start>,<stop>,<step>)
import randoma=int(input("Enter the starting number: "))
b=int(input("Enter the ending number: "))
c=int(input("Enter the updating number: "))
y=random.randrange(a,b,c) # a<=N<=b updating c
print(" Range a<=N<=b "," a= ",a," b= ",b,"c= ",c, " Random integer is: ",y )
output
Enter the starting number: 5
Enter the ending number: 56
Enter the updating number: 5
Range a<=N<=b a= 5 b= 56 Random integer is: 45
Enter the starting number: 5
Enter the ending number: 45
Enter the updating number: 7
Range a<=N<=b a= 5 b= 45 c= 7 Random integer is: 12
No comments:
Post a Comment