| 查看: 572 | 回复: 0 | ||
[资源]
python核心教程第六章课后习题9的代码
|
|
#! /usr/bin/python num=int(raw_input('Please enter a number at[0~1000]:')) unit=['zero','one','two','three','four','five','six','seven','eight','night','nine','ten'] ten=['eleven','twele','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen'] tens=['ten','twenty','thirty','fourty','fifty','sixty','seventy','eighty','ninety'] #print num #print unit #print ten #print tens def engnum(num): if num<=10: units=unit[num] print 'The english number is %s'%units elif 10< num <100: nuit1=num/10 nuit2=num%10 if nuit2==0: print 'The number is %s'%tens[nuit1-1] else: print 'The number is %s-%s'%(ten[nuit1-1],unit[nuit2]) elif 100<=num<1000: nuit3=num%10 ten3=nuit3%10 hu1=num/100 if nuit3==0 and ten3==0: print 'The number is %shunder'%unit[hu1] elif nuit3==0: print 'The number is %shunder-%s'%(unit[hu1],tens[ten3-1]) else: print 'The number is :%shunder-%s-%s'%(unit[hu1],tens[ten3-1],unit[unit3]) else: print 'ten-hunder' engnum(num) |
» 猜你喜欢
一个有机合成实验室都需要哪些设备?
已经有6人回复
2026年国自然面上资助率
已经有20人回复
面上再次挂了,太难了,躺也躺不了,倦也卷不过,小学校之殇!
已经有22人回复
微信指数没变化,科研之友没阅读
已经有18人回复
基础研究怎么拉横向,学校到款任务越来越多,难以完成 拉横向,都有哪些途径啊
已经有8人回复
HXDI做水性聚氨酯乳液,是不是特别容易出渣
已经有3人回复
系统今天又提示维护了,估计离放榜不远了
已经有15人回复
你们的时间戳变了吗
已经有4人回复
产物和副产物价值比较
已经有5人回复
时间戳他又来了
已经有17人回复










回复此楼
点击这里搜索更多相关资源