Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python program for geometric progression

#sum of terms in geometric proggression in python
x=int(input('Enter the value of x :'))
n=int(input('Enter the value of n :'))
total=1
for i in range(1,n+1):
  s=x**i
  total+=s
  print('term',i,'is',s)
print('The sum of the series 1+x+x2+x3+....+xn=',total)
#Output
Enter the value of x :2
Enter the value of n :4
term 1 is 2
term 2 is 4
term 3 is 8
term 4 is 16
The sum of the series 1+x+x2+x3+....+xn= 31
Comment

geometric progression in python

def geometric_progression(a1, n, q):
    print(a1)
    for i in range(1, n + 1):
        power = i - 1
        t = a1 * q ** power
        print(t)
Comment

PREVIOUS NEXT
Code Example
Python :: python loop through files in directory 
Python :: insert column at specific position in pandas dataframe 
Python :: group consecutive numbers in list python 
Python :: pandas groupby sum 
Python :: pandas plot use index as x 
Python :: convert 2 columns to dictionary pandas 
Python :: python parse dict from string 
Python :: modify string in python 
Python :: undefie int value python 
Python :: python popen no message 
Python :: truncate date to midnight in pandas column 
Python :: per gjera te shumta. Python 
Python :: minimum from list of tuples 
Python :: new column with age interval pandas 
Python :: filter blank rows python csv 
Python :: Mean Kurtosis of all rows pandas 
Python :: pandas replace values in column based on condition 
Python :: selenium find element by link text python 
Python :: how to include specific data type from the dataframe 
Python :: find python path windows 
Python :: Right click context menu of a file in Python 
Python :: python get date tomorrow 
Python :: pandas print dataframe dtypes 
Python :: somma in python 
Python :: Date difference in minutes in Python 
Python :: python import stringio 
Python :: rearrange list python 
Python :: tbc full form in cricket 
Python :: replacing values in pandas dataframe 
Python :: python number of elements in multidimensional array 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =