有谁能帮我用Python解一个题或者做个小游戏,题目自行设计,大概50行,

作者&投稿:娄融 (若有异议请与网页底部的电邮联系)
有谁能帮我用Python解一个题或者做个小游戏,题目自行设计,大概50行, 用到函数,难度不要太大~



#!/usr/bin/env python# -*- encoding:utf-8 -*-Integral = 0#noError = 1print "欢迎来到厨艺大比拼!".center(60)#可以自己创建这个函数,我这统一使用的这一个函数,然后下面修改调用def Choice(Each_level): if Each_level == "001":return 10 #选择001得10分 elif Each_level == "002":return 5 #选择002得5分 elif Each_level == "003":return 1 #选择003得1分 else:return 0while True: file1=raw_input("""请选择你的食材:001:黄瓜002:香蕉003:榴莲""") if not Choice(file1):continue Integral += Choice(file1) file1=raw_input("""请选择你的调料:001:酱油002:醋003:盐""") if not Choice(file1):continue Integral += Choice(file1) file1=raw_input("""请选择你的烹饪方式:001:蒸002:炒003:油炸""") if not Choice(file1):continue Integral += Choice(file1) file1=raw_input("""请选择你的烹饪时间: 001:30分钟 002:10分钟 003:12小时 """) if not Choice(file1):continue Integral += Choice(file1) break print "你的菜最后得分为:",Integral下面是输出结果

代码如下:
>>> import commands

>>> dir(commands)
['__all__', '__builtins__', '__doc__', '__file__', '__name__', 'getoutput', 'getstatus','getstatusoutput', 'mk2arg', 'mkarg']
>>> commands.getoutput("date")
'Wed Jun 10 19:39:57 CST 2009'
>>>
>>> commands.getstatusoutput("date")
(0, 'Wed Jun 10 19:40:41 CST 2009')
注意: 当执行命令的参数或者返回中包含了中文文字,那么建议使用subprocess,如果使用os.popen则会出现下面的错误:
代码如下:
Traceback (most recent call last):

File "./test1.py", line 56, inmain()
File "./test1.py", line 45, in main
fax.sendFax()
File "./mailfax/Fax.py", line 13, in sendFax
os.popen(cmd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 46-52: ordinal not inrange(128)


pyth是什么意思?
PYT 是什么意思?——一个流行的网络缩略语 PYT 是缩写形式,指代“pretty young thing”(漂亮的年轻姑娘)这个词组。通常出现在社交媒体或聊天应用的帖子或评论中,用于形容某个吸引人的年轻女性。在互联网流行文化中,缩写词已经非常普遍,帮助人们在快速的通讯中节省时间和空间。PYT 的另一种含义——...

江川县19436438676: 有谁能帮我用Python解一个题或者做个小游戏,题目自行设计,大概50行, -
潭庾更年: 代码如下: >>> import commands >>> dir(commands) ['__all__', '__builtins__', '__doc__', '__file__', '__name__', 'getoutput', 'getstatus','getstatusoutput', 'mk2arg', 'mkarg'] >>> commands.getoutput("date") 'Wed Jun 10 19:39:57 CST 2009' >>> >...

江川县19436438676: 求解Python语言作业,有哪位高手帮帮忙,急用,谢谢
潭庾更年: 晕....怎么你的也是这个做也啊?呵呵.....刚做了两题.也一样的.给你看看吧 做第七题: #!/bin/usr/python #-*-coding:GB2312-*- #filename:Fileproperties.py import os import time def Show_File_Properties(path): ''' Function_Name:Show_File_...

江川县19436438676: 我用python写了如下程序,可是后来最后出了问题.有谁帮我解决一下?? -
潭庾更年: words2是列表,所以words6也是列表,不是字典

江川县19436438676: python简单题一道 求解答 -
潭庾更年: #脚本:#!/usr/bin/env python weight=float(raw_input('please input your weight:')) high=float(raw_input('please input your high:')) print '{0:.2f}'.format(weight/(high**2))#输出:please input your weight:80 please input your high:1.7526.12

江川县19436438676: 请帮我用Python写出下面这个程序的代码 现请你编一个程序找出所有的三位数到七位数中的阿姆斯特朗 -
潭庾更年: print(' '.join(map(str, (i for i in xrange(100, 100000) if sum(int(c)**3 for c in str(i))==i))))

江川县19436438676: 谁能用python帮我编写一段小代码:如下:用户输入一个数,这个数除以2再分别除以3个数并分别打印结果! -
潭庾更年: import sysn = int(raw_input("Please input a number:")) n=n/2 dividers = [2,3,4]print map(lambda x: n/x, dividers)

江川县19436438676: python遇到一个问题!高手帮我看解决以下好嘛? -
潭庾更年: pv = present_value fv = 0 for per in range(periods): fv = pv*(1+rate_per_period) pv = fv return fv 存入1000元,年利率为2%,按年计算利息,存3年,最终的本息合计是: 1061.208 存入1000元,年利率为2%,按月计算利息,存3年,最终的本息合计是: 1061.78351496 存入1000元,年利率为2%,按天计算利息,存3年,最终的本息合计是: 1061.83480113

江川县19436438676: 题目:有关Python语言的题,急!!!!!!
潭庾更年: 晕....又碰到一个是这个做也的好友...给你贴下代码吧..哈哈 第一题: #!/usr/bin/env python#-*- coding: GB2312 -*- while True: filename = raw_input('输入文本路径:') if filename != 'exit': txtfile = file(filename, 'r+') content = txtfile.readlines() txtfile....

江川县19436438676: 哪位大侠帮我做做python的题目啊,做其中5个就好.跪求啊 -
潭庾更年: #coding:utf8#10个评委打分,去掉1最高分和1最低,最后得平均分 scoreList=[] x=0 average=0; import random while x scoreList.append(random.randint(0,100)) x+=1 print scoreList scoreList.remove(min(scoreList)) scoreList.remove(max(scoreList...

江川县19436438676: 十万火急啊,求求哪位亲可以帮我用python做一个给出日期求得星期几的程序啊,拜托了拜托了拜托了 -
潭庾更年: Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime等等,所以根本不需要你自己写啦.>>> import datetime>>> datetime.date.today() # 直接计算今天的日期datetime.date(2012, 4, 4) # 得到今天的日期>>> p=datetime.date(2011, 3, 8) #2011年3月8日>>> p.weekday() # 计算得到星期一1

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网