0

Write a program that generates a random decimal number between 1 and 10 with two decimal places of accuracy In python

20th May 2020, 3:06 PM
Elliot
4 Answers
+ 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)
20th May 2020, 3:45 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 5
Before you ask for help with your homework, please show what you have tried so far.
20th May 2020, 3:18 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 2
use random.uniform(lowerbound, upperbound) and use rounding or format it to 2 decimal points.
20th May 2020, 4:38 PM
rodwynnejones
rodwynnejones - avatar
+ 1
From random import randint X=randint(1,10,0.20) Print(x) This what I tried but remember I am beginner
20th May 2020, 3:34 PM
Elliot