0
I'm coding this for hours & can't make the value of the 5 random numbers round off to 2 decimal places like in the examples
Write a program that generates a 5 random decimal number between 1 and 100 with two decimal places of accuracy. Examples are 1.23, 3.45, 9.80, and 5.00. Compute the average of the numbers. from random import randint ##variable name= randint(minimum,maximum) num1=randint(1,100) num2=randint(1,100) num3=randint(1,100) num4=randint(1,100) num5=randint(1,100) print("num1: ", round(num1,2), sep="") print("num2: ", round(num2,2), sep="") print("num3: ", round(num3,2), sep="") print("num4: ", round(num4,2), sep="") print("num5: ", round(num5,2), sep="") average=(num1+num2+num3+num4+num5)/5 print("average: ", average)
6 odpowiedzi
+ 3
Erika Abalora
`randint` returns a random integer. What you want is a float number. Try the `uniform` function, which returns a random float in the given range:
from random import uniform
num1=uniform(1,100)
...
+ 1
Erika Abalora Meaning you are only allowed to use randint and nothing else?
+ 1
You're welcome :)
+ 1
How I use this app
0
but we are still not on that part
I'm afraid, it will be counted as we are still in the basics of randint
0
it worked, thankyouuuuuuu