6.4.. Generisati dva trocifrena slučajna broja. Sabrati cifre desetica prvog i stotice drugog broja i obratno.
Listing programa:
# 06421139
from random import randint
a = randint(100, 999)
b = randint(100, 999)
print("a= ",a)
print("b= ",b)
print()
d1 = int((a%100)/10)
print("d1= ",d1)
d2 = int((b%100)/10)
print("d2= ",d2)
print()
s1 = int((a%1000)/100)
print("s1 = ",s1)
s2 = int((b%1000)/100)
print("s2= ",s2)
print()
x = d1 + s2
y = d2 + s1
print("d1+s2= ",x)
print("d2+s1= ",y)
Ispis na ekranu:
Index
|
|