0
Write a program that generates a random decimal number between 1 and 10 with two decimal places of accuracy In python
4 Réponses
+ 6
randint comes from random integer, so it will give you an integer value. What you are looking for is random.random, which returns a float from 0 to 1. Then just multiply it by 10.
Or use random.randrange:
from random import randrange
x=randrange(1,1000, 1) / 100
print(x)
+ 5
Before you ask for help with your homework, please show what you have tried so far.
+ 2
use random.uniform(lowerbound, upperbound) and use rounding or format it to 2 decimal points.
+ 1
From random import randint
X=randint(1,10,0.20)
Print(x)
This what I tried but remember I am beginner