神剑山庄资源网 Design By www.hcban.com

Python有四种类型的数字:
1.整型 

a = 2 
print a 

2.长整型 

b = 123456789 
print b 

3.浮点数 

c = 3.2E2 
print c 

4.复数 复数为实数的推广,它使任一多项式都有根。复数当中有个“虚数单位”j,它是-1的一个平方根。任一复数都可表达为x+yj,其中x及y皆为实数,分别称为复数之“实部”和“虚部”。  

d = (2+3j) 
print d 

 

计算示例:
每种程序语言都有数学计算方法,数学符号通用,大家都知道。直接上代码吧:

print "I will now count my chickens:" 
 
 
print "Hens", 25 + 30 / 6 
print "Roosters", 100 - 25 * 3 % 4 
 
 
print "Now I will count the eggs:" 
 
 
print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 
 
 
print "Is it true that 3 + 2 < 5 - 7" 
 
 
print 3 + 2 < 5 - 7 
 
 
print "What is 3 + 2", 3 + 2 
print "What is 5 - 7", 5 - 7 
 
 
print "Oh, that's why it's False." 
 
 
print "How about some more." 
 
 
print "Is it greater", 5 > -2 
print "Is it greatet or equal", 5 >= -2 
print "is it less or equal", 5 <= -2 


运行结果应该是这样的:

root@he-desktop:~/mystuff# python ex3.py 
I will now count my chickens:
Hens 30
Roosters 97
Now I will count the eggs:
7
Is it true that 3 + 2 < 5 - 7"htmlcode">
my_height_centimeter = my_height * 2.54 
my_weight_kilo = my_weight * 0.4536 
print "He's %d centimeters tall." % my_height_centimeter 
print "He's %d kilos heavy." % my_weight_kilo  


标签:
Python,数字,计算

神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网 免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com

评论“简单讲解Python中的数字类型及基本的数学计算”

暂无简单讲解Python中的数字类型及基本的数学计算的评论...

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。