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)

6th Feb 2023, 4:23 PM
Ela
+ 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) ...
6th Feb 2023, 4:43 PM
Mozzy + 2
Also, num=randint(1,10000)/100 print('%7.2f'%num)
6th Feb 2023, 6:36 PM
Jay Matthews + 1
Erika Abalora Meaning you are only allowed to use randint and nothing else?
6th Feb 2023, 4:55 PM
Mozzy + 1
You're welcome :)
6th Feb 2023, 4:58 PM
Mozzy + 1
How I use this app
8th Feb 2023, 2:42 PM
Priyam Ghosh 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
6th Feb 2023, 4:45 PM
Ela
0
it worked, thankyouuuuuuu
6th Feb 2023, 4:55 PM
Ela