6.4.. Sabrati cifre dva generisana trocifrena slučajna broja.
Listing programa:
# 06421126
from random import randint
a = randint(100, 999)
b = randint(100, 999)
s = a + b
print("a= ",a)
print("b= ",b)
print(a," + ",b," = ",s)
II Varijanta
import random
a=random.randint(100, 999)
b=random.randint(100, 999)
s=0
print("Brojevi su: ", a, b)
while(a>0):
x=a%10
s+=x
a=int(a/10)
while(b>0):
y=b%10
s+=y
b=int(b/10)
print("Suma cifara brojeva je: ", s)
Ispis na ekranu:
Index
|
|