For13. An integer N (>0) is given. Find the value of expression
\(1.1 - 1.2 + 1.3 - ...\)
(N terms, the signs alternate). Do not use a conditional statement.

Solution in Python 3:

import random

N = random.randrange(1,15)
print('N = ', N)

S = 0.0
for i in range(1,N+1):
x = (1 + i*0.1)*(-1)**(i+1)
S += x
print(i," : ",x," : ",S)
print("Sum = ",S)