Q. Write a program that generates a series using a function which takes first and last values of the series and then generates four terms that are equidistant e.g., if two numbers passed are 1 and 7 then function returns 1 3 5 7.


You can understand by Watching video :-



Answer :-

def ser(    a  , b ) :
    d = int ( ( b - a ) / 3 )
    print("Series = " , a , a + d , a + 2*d , b )

first = int(input("Enter first Term = "))
last = int(input("Enter last Term = "))

ser(first , last )

Output :-

Enter first Term = 1
Enter last Term = 7
Series =  1 3 5 7

>>> 

Enter first Term = 7
Enter last Term = 1
Series =  7 5 3 1

>>> 

Enter first Term = 2
Enter last Term = 8
Series =  2 4 6 8

>>> 

Enter first Term = 100
Enter last Term = 60
Series =  100 87 74 60

>>> 



4 Comments

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

Post a Comment

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

Previous Post Next Post