- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
python程序练习题集
1.#输⼊a,b,c,d4个整数,计算a+b-c*d的结果
a=input(please input a nimber:)
b=input(please input a number:)
c=input(please input a number:)
d=input(please input a number:)
print a+b-c*d
输出结果:
please input a nimber:3
please input a number:3
please input a number:3
please input a number:3
-3
2.#计算⼀个12.5m*16.7m的矩形房间的⾯积和周长
a=12.5
b=16.7
s=a*b
c=a+a+b+b
print ⾯积 %f,周长 %f%(s,c)
输出结果
⾯积 208.750000,周长 58.400000
3.#怎么得到9/ 的⼩数结果
float(9/2)
4.0
4.#python计算中7*7*7*7.可以有多少种写法
第⼀种:
7*7*7*7
2401
第⼆种:
pow (7,4)
2401
第三种:
7**4
24401
第四种:
eval(%s*%s*%s*%s%(7,7,7,7))
2401
第五种:
a=7
for i in range(3):
... a*=7
...
a
2401
第六种:
*7*4
*7*7*7*7
*7*4[1:]
Traceback (most recent call last)
File stdin, line 1, in mod
TypeError: int object has no at
(*7*4)[1:]
7*7*7*7
eval((*7*4)[1:])
2401
第七种:
a=[7]*4
*.join(a)
7*7*7*7
eval(*.join([7]*4))
2401
5.#写程序将温度从华⽒温度转换为摄⽒温度。转换公式为C=5/9*(F-32)
def FtoC(degree):
... return float(%.2f %(5.0*100/9*(degree-32)/100))
...
print FtoC(100)
37.78
6.#⼀家商场在降价促销。如果购买⾦额50-100元(包含50元和100元)之间,会给10%的折扣,如果购买⾦额⼤于100元会给20%折扣。编写
⼀程序,询问购买价格,再显⽰出折扣(%10或20%)和最终价格
#coding=utf-8
customer_price=float(raw_input(please input pay money:))
if customer_price =50 and customer_price=100:
print disconunt 10%% ,after discount you shoud pay %s \
%(customer_price*(1-0.1))
elif customer_price 100:
print disconunt 20%% ,after discount you shoud pay %s \
%(customer_price*(1-0.2))
else:
print disconunt 0%% ,after discount you shoud pay %s \
%customer_price
7.#判断⼀个数n能同时被3和5整除
while 1:
n=input(please input a number:)
if n%3==0 and n%5==0:
print the number 可以同时被3和5整除
else:
printinput again!
输出结果:
please input a number:1
the number 可以同时被3和5整除
please input a number:4
input again!
please input a number:5
input again!
please input a number:
8.#求1+2+3+...+100 (第⼀种)
s=0
for i in range(101)
文档评论(0)