CBSE Class 12 Computer Science
Question 53 of 62
Using Python Libraries — Question 6
Back to all questions 6
Question import random
def diff():
x = random.random() - random.random()
return(x)
y = diff()
print(y)0.006054151450219258
-0.2927493777465524
Output will be a floating-point number representing the difference between two random numbers. Since every call to random() function of random module generates a new number, hence the output will be different each time we run the code.