- “笨辦法”學(xué)Python 3
- (美)澤德 A.肖
- 351字
- 2020-01-16 10:58:02
習(xí)題3 數(shù)字和數(shù)學(xué)計(jì)算

每一種編程語言都包含處理數(shù)字和進(jìn)行數(shù)學(xué)計(jì)算的方法。不必?fù)?dān)心,程序員經(jīng)常謊稱他們是多么牛的數(shù)學(xué)天才,其實(shí)他們根本不是。如果他們真是數(shù)學(xué)天才,他們就會(huì)去從事數(shù)學(xué)相關(guān)的工作,而不是寫一些毛病百出的Web框架,想著賺夠錢買輛跑車了。
這個(gè)習(xí)題里有很多數(shù)學(xué)運(yùn)算符號(hào)。我們來看一遍它們都叫什么名字,你要一邊寫一邊念出它們的名字來,直到你念煩了為止。名字如下。
· +:加號(hào)。
· -:減號(hào)。
· /:斜杠。
· *:星號(hào)。
· %:百分號(hào)。
· <:小于號(hào)。
· >:大于號(hào)。
· <=:小于等于號(hào)。
· >=:大于等于號(hào)。
有沒有注意到以上只是些符號(hào),沒有給出具體的運(yùn)算操作呢?錄完下面的習(xí)題代碼后,再回到上面的列表,寫出每個(gè)符號(hào)的作用。例如,+是用來做加法運(yùn)算的。
ex3.py
1 print("I will now count my chickens:") 2 3 print("Hens", 25+30/ 6) 4 print("Roosters", 100-25*3%4) 5 6 print("Now I will count the eggs:") 7 8 print(3+2+1-5+4%2-1/4+6) 9 10 print("Is it true that 3 + 2 < 5-7? ") 11 12 print(3+2<5-7) 13 14 print("What is 3 + 2? ", 3+2) 15 print("What is 5-7? ", 5-7) 16 17 print("Oh, that′s why it′s False.") 18 19 print("How about some more.") 20 21 print("Is it greater? ", 5>-2) 22 print("Is it greater or equal? ", 5>=-2) 23 print("Is it less or equal? ", 5<=-2)
推薦閱讀
- Learning Neo4j
- Game Programming Using Qt Beginner's Guide
- 軟件架構(gòu)設(shè)計(jì):大型網(wǎng)站技術(shù)架構(gòu)與業(yè)務(wù)架構(gòu)融合之道
- Visual C++數(shù)字圖像模式識(shí)別技術(shù)詳解
- Spring Boot+Spring Cloud+Vue+Element項(xiàng)目實(shí)戰(zhàn):手把手教你開發(fā)權(quán)限管理系統(tǒng)
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Mastering Google App Engine
- Mastering ServiceNow(Second Edition)
- Getting Started with Gulp
- Yii Project Blueprints
- Kubernetes進(jìn)階實(shí)戰(zhàn)
- Mastering Gephi Network Visualization
- JavaScript前端開發(fā)基礎(chǔ)教程
- Sitecore Cookbook for Developers
- Building a Media Center with Raspberry Pi