w3resource
Python Exercises

Python: Print the length of the series and the series from the given 3rd term , 3rd last term and the sum of a series

Python Basic - 1: Exercise-28 with Solution

Write a Python program to print the length of the series and the series from the given 3rd term , 3rd last term and the sum of a series.

Input data:
3rd term - 3
3rd last term - 118 55
Sum of the series - 91

Sample Solution:

Python Code:

tn = int(input("Input third term of the series:"))
tltn = int(input("Input 3rd last term:"))
s_sum = int(input("Sum of the series:"))
n = int(2*s_sum/(tn+tltn))
print("Length of the series: ",n)
d = (tltn-tn)/(n-5)
a = tn-2*d
j = 0
print("Series:")
for j in range(n-1):
  print(int(a),end=" ")
  a+=d
print(int(a),end=" ")

Sample Output:

Input third term of the series: 3
Input 3rd last term: 118
Sum of the series: 91
Length of the series:  1
Series:
60 

Flowchart:

Flowchart: Python - Print the length of the series and the series from the given 3rd term , 3rd last term and the sum of a series.

Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to find the type of the progression (arithmetic progression/geometric progression) and the next successive member of a given three successive members of a sequence.
Next: Write a Python program to find common divisors between two numbers in a given pair.

What is the difficulty level of this exercise?