jeudi 7 mai 2020

How to find the max value of a set of randomly generated numbers that is divisible by 7?

I know this might be a very easy question but I can't get my head around it. The question asks to generate 357 random numbers between 8 and 254 (inclusive) and print out the largest generated number that is exactly divisible by 7.

I wrote this program:

import random

def main():
    for x in range(357):
      print (random.randint(8,254)*7),

print

main()

which generates the numbers but I don't know how to get the max number out of it. I would really appreciate any help 🙏




Aucun commentaire:

Enregistrer un commentaire