Q. Write a program that generates 4 terms of an AP by providing initial and step values to a function that returns first four terms of the series.


Answer :-


def retSeries (init, step):
    return init, init + step, init + 2*step, init + 3*step

ini = int (input ("Enter initial value of the AP series : "))
st = int(input ("Enter step value of the AP series : "))
print("Series with initial value ", ini, " & step value", st, "goes as: ")
t1, t2, t3, t4 = retSeries (ini, st)
print (t1, t2, t3, t4)


Output :-

Enter initial value of the AP series : 2
Enter step value of the AP series : 3
Series with initial value  2  & step value 3 goes as:
2 5 8 11

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post