猜数字游戏

题目:猜数字游戏(要求:用户有三次机会输入数字,当机会用完和输入正确退出,游戏结束.)

代码:

# encoding: utf-8

import random

print('------------我爱鱼c工作室------------')

ran = random.randint(1, 10)

print('随机数为:', ran)

count =3

while count:

        temp =input('不防猜一下小甲鱼心里想的是哪个数字<1-10>:')

        guess =int(temp)

        count = count -1  # 用户每用一次,机会就少一

        if guess == ran:

            print('窝草,你是小甲鱼心里的蛔虫吗?!')

            print('哼,猜中了也没有奖励!')

            break

        else:

            if guess > ran:

                    print('哥,大了大了~~~')

            if guess < ran:

                    print('哥,小了小了~~~')

print('游戏结束,不玩了^_^')

你可能感兴趣的:(猜数字游戏)