Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- a = int(random.randint (1,100)) #a is a random integer from 1 to 100
- total = 0 #this is the sum of all your numbers
- largest = 0 #this is the largest out of all your numbers
- for i in range (5): #printing 5 random numbers
- a = int(random.randint (1,100)) #printing random #s between 1 to 100
- total += a #to add numbers, we add the previous number to the current num.
- 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
- print(a) #printing each number
- if a > largest: #if the random number is greater than the largest(a>a)
- largest = a #... we define that the largest = the highest value for a
- print("The largest number in the set is " + str(a) + ".")
- print(str(total) + " is the sum of your numbers!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement