0% found this document useful (0 votes)
4 views2 pages

Python Program 1st Program

The Python program calculates the sum of a geometric series based on user inputs for 'a' and 'n'. If 'a' equals 1, it computes the sum as 'n + 1'; otherwise, it uses the formula (a^(n + 1) - 1) / (a - 1). The program successfully outputs the sum of the series for the given inputs.

Uploaded by

Rama Chandran
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python Program 1st Program

The Python program calculates the sum of a geometric series based on user inputs for 'a' and 'n'. If 'a' equals 1, it computes the sum as 'n + 1'; otherwise, it uses the formula (a^(n + 1) - 1) / (a - 1). The program successfully outputs the sum of the series for the given inputs.

Uploaded by

Rama Chandran
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PYTHON PROGRAM

# Get the value of a and n from the user

a = float(input("Enter the value of a: "))

n = int(input("Enter the value of n: "))

# Calculate the sum of the series


if a == 1:

total_sum = n + 1

else:

total_sum = (a**(n + 1) - 1) / (a - 1)

# Print the sum of the series

print("The sum of the series is:", total_sum)

OUTPUT

Enter the value of a: 2

Enter the value of n: 2

The sum of the series is: 7.0

=== Code Execution Successful ===

--------------------------------------------------------------------------------------------------------------------------------------

You might also like