日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:計(jì)算等比數(shù)列和

創(chuàng)新互聯(lián)python教程:

公司主營業(yè)務(wù):網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出扶余免費(fèi)做網(wǎng)站回饋大家。

寫一個(gè) Python 程序,用實(shí)例求等比數(shù)列(G.P .級數(shù))的和。

Python 通用編程系列

等比數(shù)列是一個(gè)元素序列,其中下一個(gè)項(xiàng)目通過乘以上一個(gè)項(xiàng)目的公約數(shù)而獲得。或者 G.P. Series 是一系列數(shù)字,其中任何連續(xù)數(shù)字(項(xiàng)目)的公共比率總是相同的。

G.P 系列之和 Sn = a(rn)/(1-r) Tn = ar(n-1)背后的數(shù)學(xué)公式

Python 程序求等比數(shù)列和的例子

這個(gè) Python 程序允許用戶輸入第一個(gè)值、一系列項(xiàng)目的總數(shù)和公共定額。接下來,它找到等比數(shù)列的和。

# Python Program to find Sum of Geometric Progression Series
import math

a = int(input("Please Enter First Number of an G.P Series: : "))
n = int(input("Please Enter the Total Numbers in this G.P Series: : "))
r = int(input("Please Enter the Common Ratio : "))

total = (a * (1 - math.pow(r, n ))) / (1- r)
tn = a * (math.pow(r, n - 1))

print("\nThe Sum of Geometric Progression Series = " , total)
print("The tn Term of Geometric Progression Series = " , tn)

不用數(shù)學(xué)公式求等比數(shù)列和的程序

在這個(gè) Python 程序中,我們沒有使用任何數(shù)學(xué)公式。

# Python Program to find Sum of Geometric Progression Series

a = int(input("Please Enter First Number of an G.P Series: : "))
n = int(input("Please Enter the Total Numbers in this G.P Series: : "))
r = int(input("Please Enter the Common Ratio : "))

total = 0
value = a
print("\nG.P  Series :", end = " ")
for i in range(n):
    print("%d  " %value, end = " ")
    total = total + value
    value = value * r

print("\nThe Sum of Geometric Progression Series = " , total)

等比數(shù)列輸出的 Python 和

Please Enter First Number of an G.P Series: : 1
Please Enter the Total Numbers in this G.P Series: : 5
Please Enter the Common Ratio : 4

G.P  Series : 1   4   16   64   256   
The Sum of Geometric Progression Series =  341

用函數(shù)計(jì)算等比數(shù)列和的 Python 程序

這個(gè) Python 等比數(shù)列程序與第一個(gè)示例相同。然而,在這個(gè) Python 程序中,我們使用函數(shù)來分離邏輯。

# Python Program to find Sum of Geometric Progression Series
import math

def sumofGP(a, n, r):
    total = (a * (1 - math.pow(r, n ))) / (1- r)
    return total

a = int(input("Please Enter First Number of an G.P Series: : "))
n = int(input("Please Enter the Total Numbers in this G.P Series: : "))
r = int(input("Please Enter the Common Ratio : "))

total = sumofGP(a, n, r)
print("\nThe Sum of Geometric Progression Series = " , total)

寶潔系列輸出的 Python 和

Please Enter First Number of an G.P Series: : 2
Please Enter the Total Numbers in this G.P Series: : 6
Please Enter the Common Ratio : 3

The Sum of Geometric Progression Series =  728.0

網(wǎng)站欄目:Python程序:計(jì)算等比數(shù)列和
本文URL:http://www.dlmjj.cn/article/ccoepos.html