Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import random
  2.  
  3. a = int(random.randint (1,100)) #a is a random integer from 1 to 100
  4. total = 0 #this is the sum of all your numbers
  5. largest = 0 #this is the largest out of all your numbers
  6.  
  7. for i in range (5): #printing 5 random numbers
  8. a = int(random.randint (1,100)) #printing random #s between 1 to 100
  9. total += a #to add numbers, we add the previous number to the current num.
  10. largest = a #the largest number in the set has to be a, but since we don't know what it will be, we set the largest to a because a is the great number in the set
  11. print(a) #printing each number
  12. if a > largest: #if the random number is greater than the largest(a>a)
  13. largest = a #... we define that the largest = the highest value for a
  14. print("The largest number in the set is " + str(a) + ".")
  15. print(str(total) + " is the sum of your numbers!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement