fork download
  1. #A Python code that generates 7 random numbers between the range(1,20) and finds the average of those numbers
  2.  
  3. #import library
  4. from numpy import random
  5. #Generate 7 random numbers
  6. num1 = random.randint(1,20)
  7. print("The first random number is: ", num1)
  8. num2 = random.randint(1,20)
  9. print("The second random number is: ", num2)
  10. num3 = random.randint(1,20)
  11. print("The third random number is: ", num3)
  12. num4 = random.randint(1,20)
  13. print("The fourth random number is: ", num4)
  14. num5 = random.randint(1,20)
  15. print("The fifth random number is: ", num5)
  16. num6 = random.randint(1,20)
  17. print("The sixth random number is: ", num6)
  18. num7 = random.randint(1,20)
  19. print("The seventh random number is: ", num7)
  20. #Find the average of those 7 numbers
  21. sumNums = num1 + num2 + num3 + num4 + num5 + num6 + num7
  22. Total = sumNums
  23. print("The average of the seven numbers is: ", Total/7)
  24.  
  25. #Program exits
  26.  
  27.  
  28.  
Success #stdin #stdout 0.22s 26948KB
stdin
Standard input is empty
stdout
The first random number is:  3
The second random number is:  8
The third random number is:  3
The fourth random number is:  1
The fifth random number is:  1
The sixth random number is:  1
The seventh random number is:  11
The average of the seven numbers is:  4.0