国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Python > 正文

舉例講解Python中的算數(shù)運(yùn)算符的用法

2019-11-25 17:29:12
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

下表列出了所有Python語(yǔ)言支持的算術(shù)運(yùn)算符。假設(shè)變量a持有10和變量b持有20,則:

2015513115413853.jpg (585×361)

 例子:

試試下面的例子就明白了所有的Python編程語(yǔ)言提供了算術(shù)運(yùn)算符:

#!/usr/bin/python

a = 21
b = 10
c = 0

c = a + b
print "Line 1 - Value of c is ", c

c = a - b
print "Line 2 - Value of c is ", c

c = a * b
print "Line 3 - Value of c is ", c

c = a / b
print "Line 4 - Value of c is ", c

c = a % b
print "Line 5 - Value of c is ", c

a = 2
b = 3
c = a**b
print "Line 6 - Value of c is ", c

a = 10
b = 5
c = a//b
print "Line 7 - Value of c is ", c

當(dāng)執(zhí)行上面的程序,它會(huì)產(chǎn)生以下結(jié)果:

Line 1 - Value of c is 31
Line 2 - Value of c is 11
Line 3 - Value of c is 210
Line 4 - Value of c is 2
Line 5 - Value of c is 1
Line 6 - Value of c is 8
Line 7 - Value of c is 2

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 同德县| 柘荣县| 通江县| 馆陶县| 班玛县| 科技| 同江市| 扎囊县| 高陵县| 英德市| 南华县| 临澧县| 汉源县| 南充市| 广平县| 东莞市| 盐池县| 浙江省| 马龙县| 灵丘县| 浪卡子县| 博野县| 蕉岭县| 双辽市| 桃江县| 柳州市| 读书| 浦北县| 星子县| 抚顺市| 左权县| 宝坻区| 自贡市| 昭觉县| 东乌珠穆沁旗| 荆州市| 桐梓县| 辰溪县| 靖州| 平南县| 前郭尔|