Series29. Integers K, N and K sets of integers with N elements in each set are given. Output the total sum of all elements included in these sets.

Solution in Python 3:

import random

N = random.randrange(1,7)
K = random.randrange(1,7)

print("N = ",N)
print("K = ",K)
S = 0
for i in range(0,K):
for j in range(0,N):
x = random.randrange(0,4)
print(x,end="; ")
S += x
print()

print()
print("Sum = ",S)