Computer Science, asked by Anonymous, 7 months ago

\huge{\frak{Bonjour!}}


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.
#PythonProgramming​

Answers

Answered by santoshsharma542141
2

Answer:

follow me ❣️

Explanation:

# Code

def func(x, y):

d = (y-x)/3 # divides the difference in 3 equal parts

return [x, x+d, x+2*d, y] # returns the series as a list

print(func(1, 9))

print(func(4, 8))

print(func(4, 10))

print(func(1, 7))

# Output

[1, 3.6666666666666665, 6.333333333333333, 9] [4, 5.333333333333333, 6.666666666666666, 8] [4, 6.0, 8.0, 10] [1, 3.0, 5.0, 7]

Answered by TeraBhaii
35

\large{\underline{\sf{Coding:--}}}

def func(x, y):

d = (y-x)/3 # divides the difference in 3 equal parts

return [x, x+d, x+2*d, y] # returns the series as a list

>>>print(func(1, 9))

>>>print(func(4, 8))

>>>print(func(4, 10))

>>>print(func(1, 7))

Output:-

[1, 3.6666666666666665, 6.333333333333333, 9] [4, 5.333333333333333, 6.666666666666666, 8] [4, 6.0, 8.0, 10] [1, 3.0, 5.0, 7]

\large\ddot{\smile}\:\frak{shubhra♡?????!}

Similar questions