Answer the question
In order to leave comments, you need to log in
I can't solve the problem. Random multiples of 5?
Application certification CC-Python level 7. Problem №32 Random multiples 5. The
computer generates 300 random numbers in the range from 0 to 100 inclusive. Calculate the percentage of the resulting multiples of 7 numbers. In the first line, import the random library.
import random
c, count = 0, 300
p = (c / count) * 100
for i in range(count):
r = random.randint(0, 100)
if (r % 7 == 0):
c += 1
print(f"{p}%")
Answer the question
In order to leave comments, you need to log in
The error is most likely due to the fact that you are trying to compile in the second python, but it should be in the 3rd.
Well, the code itself with logical errors, first you need to do a loop, then only calculate the percentage, something like this:
https://www.online-python.com/mPtwa5nMHO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question