当前位置:考试网  > 试卷库  > 计算机类  > 等级考试  > 计算机二级  > Python语言程序设计  >  请用 Python 语言编写一个简易的猜数字游戏程序。
试题预览

请用 Python 语言编写一个简易的猜数字游戏程序。

查看答案
收藏
纠错
正确答案:

import random

answer = random.randint(1,10)

print('猜数游戏 ')

num=input('请输入你猜测的数字 n')

guess=int(num)

n=0

while n<2:

if guess == answer and n==0:

print('么么哒。对啦 ')

print('厉害了一次就对了 ')

break

if guess < answer:

print('不对哦,太小了 ')

elif guess > answer :

print('不对哦,太大了 ')

elif guess==answer :

print('么么哒。对啦 ')

num=input('请你重新输入 n')

guess=int(num)

n=n+1

if n==1 and guess==answer:

print('可以哦,第二次就对了 ')

break

elif n==2 and guess ==answer:

print('还行,终于猜出来了 ')

break

elif n==2 and guess !=answer :

print('不行哦,三次都不对 ')

break

print('游戏结束 ')

答案解析:

暂无解析

你可能感兴趣的试题

请分别说明Python中正则表达式、lambda函数、装饰器、异常处理、断言处理各自的用途。

在Python中如何实现二维数组、结构体、结构体数组(二维表)、链表?请举例说明。

在数据管理技术发展过程中,文件系统与数据库系统的主要区别是数据库系统具有

执行以下程序,输入qp,输出结果是:

k=0

whileTrue:

s=input('请输入q退出:')

ifs=='q':

k+=1

continue

else:

k+=2

break

print(k)

以下选项错误描述的是

热门试题 更多>
Intheearlieststagesofman'sdevelopmenthehadnomoreneedofmoneythananimalshave.Hewascontentwithverysimpleformsofshelter,madehisownroughtoolsandweaponsandcouldprovidefoodandclothingforhimselfandhisfamilyfromnaturalmaterialsaroundhim.Ashebecamemorecivilized,however,hebegantowantbettershelter,moreefficienttoolsandweapons,andmorecomfortableandmorelastingclothingthancouldbeprovidedbyhisownneighborhoodorbytheworkofhisownunskilledhands.Forthesethingshehadtoturntotheskilledpeoplesuchassmiths,leatherworkersorcarpenters.Itwasthenthatthequestionofpaymentarose. Atfirsthegotwhathewantedbyasimpleprocessofexchange.Thesmithwhohadnotthetimetolookafterlandorcattlewasgladtotakemeatorgrainfromthefarmerinexchangeforanaxeoraplough.Butasmoreandmoregoodswhichhadnofixedexchangevaluecameonthemarket,exchangebecametoocomplicatedtobesatisfactory.Anotherproblemarosewhenthosewhomadethingswantedtogetstocksofwoodorleather,oriron,buthadnothingtoofferinexchangeuntiltheirfinishedgoodswereready.Thusthedifficultiesofexchangeledbydegreestotheinventionofmoney.Insomecountrieseasilyhandledthingslikeseedsorshellsweregivenacertainvalueandthefarmer,insteadofpayingthesmithforanewaxebygivinghimsomemeatorgrain,gavehimsomanyshells.Ifthesmithhadanyshellsleftwhenhehadboughthisfood,hecouldgetstocksoftherawmaterialsofhistrade.Insomecountriesquitelargethingssuchascowsorcamelsorevenbigflatstoneswereusedfortrade.Later,piecesofmetal,bearingvaluesaccordingtotherarityofthemetalandthesizeofthepieces,orcoinswereused.Moneyasweknowithadarrived. 1.Exchangeofgoodsbecamedifficultbecause_________. Amanbecamemorecivilized Bsmithsbegantolookafterlandorcattleintheirsparetime Cmoreandmoregoodswhichhadnofixedexchangealuescametothemarker Dfarmershadn'tenoughgrainormeattoprovidefor skilledworkers 2.Moneywasnotuseduntil_______. Apaperwasinvented Bpeoplepracticedasimpleprocessofexchange CnothingcouldbeofferedinexchangeDtheexchangeofonethingforanotherbecametoocomplicated 3.Thebesttitleforthispassageis_____. AWhatismoney BWhataremoney'sfunctions. CTheimportanceofmoney DThebeginningofmoney
试题分类: 阅读
练习次数:12次
试题分类: 口语
练习次数:0次
试题分类: 初级(口语)
练习次数:45次
试题分类: 口语
练习次数:0次
试题分类: 口语
练习次数:0次
扫一扫,手机做题