首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

两个Python习题

2013-08-21 
两个Python练习题1.假设校园电费是0.6元/千瓦时,输入这个月使用了多少千瓦时的点,算出你要交的电费。假如你

两个Python练习题
1.假设校园电费是0.6元/千瓦时,输入这个月使用了多少千瓦时的点,算出你要交的电费
。假如你只有1元和1毛的硬币,请问各需要多少1元和1毛的硬币。
输入输出:
输入这个月使用的电量:11
电费:6.6
共需6张1元和6张1毛

def docode():     strKey = 'abcdefghijklmnopqrstuvwxyz'     strValue = 'qwertyuiopasdfghjklzxcvbnm'     strIn = raw_input('please enter some words:')     dictDecode = {}     strOut = ''     for i in range(len(strKey)):          dictDecode[strKey[i]] = strValue[i]     for i in range(len(strIn)):          strOut += dictDecode[strIn[i]]     print 'decode result is :%s' % (strOut)


>>> decode()
please enter some words:helloworld
decode result is :itssgvgksr

热点排行