Python program to Get Sum of Random of 3 Digit Numbers

from random import random
x = random()*900+100
x = int(x)
print('Three random numbers =',x)
s = str(x)
y = int(s[0])#x//100
z = int(s[1])#(x//10)%10
w = int(s[2])#x % 10
print('Sum of the random numbers =',y+z+w)

 

 

Output:

Three random numbers = 715
Sum of the random numbers = 13

 

Three random numbers = 448
Sum of the random numbers = 16

 

Subscribe For Daily Updates