# coding =utf-8
import random def roll_dice(number=3, points=None):
if points == None:
points = []
while number > 0:
point = random.randrange(1,7)
points.append(point)
number = number - 1 return points def roll_result(total):
print('<<<<< ROLL THE DICE! >>>>>')
if 3 < total <10 :
return 'Small'
else:
return 'Big' def start_game():
Money = 1000
while Money > 0:
print('<<<<< GAME STAR! >>>>>')
print('You have',Money,'now') you_bet = int(input('How much you wanna bet ? -'))
judge = you_bet > Money #判断赌金是否超过本金
while judge:
print('You have not enough money,enter again :')
you_bet = int(input('How much you wanna bet ? -'))
judge = you_bet > Money choices =['Big', 'Small']
your_choice = input('Big or Small :') if your_choice in choices:
poins = roll_dice()
total = sum(poins)
result = roll_result(total)
youWin = your_choice == result
if youWin:
Money = Money +you_bet
print('YOU WIN! the point are ' , poins,'you get',you_bet) else :
Money = Money - you_bet
print('YOU LOSE! the point are ' , poins,'you lose',you_bet) else :
print('Invalid words')
start_game()
print('<<<<<GAME OVER! >>>>>') start_game()

[Python学习之路] 猜大小游戏的更多相关文章

  1. Python学习之路【第一篇】-Python简介和基础入门

    1.Python简介 1.1 Python是什么 相信混迹IT界的很多朋友都知道,Python是近年来最火的一个热点,没有之一.从性质上来讲它和我们熟知的C.java.php等没有什么本质的区别,也是 ...

  2. python学习之路-day2-pyth基础2

    一.        模块初识 Python的强大之处在于他有非常丰富和强大的标准库和第三方库,第三方库存放位置:site-packages sys模块简介 导入模块 import sys 3 sys模 ...

  3. Python学习之路-Day1-Python基础

    学习python的过程: 在茫茫的编程语言中我选择了python,因为感觉python很强大,能用到很多领域.我自己也学过一些编程语言,比如:C,java,php,html,css等.但是我感觉自己都 ...

  4. Python学习之路-Day2-Python基础3

    Python学习之路第三天 学习内容: 1.文件操作 2.字符转编码操作 3.函数介绍 4.递归 5.函数式编程 1.文件操作 打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个 ...

  5. Python学习之路-Day2-Python基础2

    Python学习之路第二天 学习内容: 1.模块初识 2.pyc是什么 3.python数据类型 4.数据运算 5.bytes/str之别 6.列表 7.元组 8.字典 9.字符串常用操作 1.模块初 ...

  6. Java程序,猜大小游戏

    一个骰子,通常有1.2.3.4.5.6等6种点数.我们将1.2.3记作“小”,将4.5.6记作“大”.猜中显示“猜对了”,猜错记作“猜错了”之类的字样.本程序可以用Java实现. import jav ...

  7. python学习之路网络编程篇(第四篇)

    python学习之路网络编程篇(第四篇) 内容待补充

  8. python 学习之路开始了

    python 学习之路开始了.....记录点点滴滴....

  9. python基础实战之猜年龄游戏

    目录 一.Python基础实战之猜年龄游戏 给定年龄,用户可以猜三次年龄 年龄猜对,让用户选择两次奖励 用户选择两次奖励后可以退出 age = 18 # 答案 count = 0 # 游戏次数控制 p ...

随机推荐

  1. Linux多线程实践(5) --Posix信号量与互斥量解决生产者消费者问题

    Posix信号量 Posix 信号量 有名信号量 无名信号量 sem_open sem_init sem_close sem_destroy sem_unlink sem_wait sem_post ...

  2. 分布式进阶(十) linux命令行下载文件以及常用工具:wget、Prozilla、MyGet、Linuxdown、Curl、Axel

    linux命令行下载文件以及常用工具:wget.Prozilla.MyGet.Linuxdown.Curl.Axel 本文介绍常用的几种命令行式的下载工具:wget.Prozilla.MyGet.Li ...

  3. Leetcode_28_Implement strStr

    本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/41452047 Implement strStr(). Re ...

  4. linux:你不知道的echo

    linux的echo命令功能是在显示器上显示一段文字.一般格式为: echo [ -n ] 字符串.参数n是指行尾不换行 echo会将输入的字符串送往标准输出.输出的字符串间以空白字符隔开, 并在最后 ...

  5. 《15个提高Google搜索的技巧》

    为了得到更加「多元化」的搜索结果,虽然 Google 目前访问起来并不是那么方便,但是仍然有很多人把它作为常用搜索引擎在使用. 其实除了最简单的关键词搜索之外,搜索引擎还提供了很多精细化的搜索功能,如 ...

  6. Windows CE Notification API的使用方法

    1 引言      以Windows CE 为操作系统的掌上电脑(如PocketPC或HPC),除具备PC的功能外,还具备很强的自身控制能力.Windows CE API超越微软其他操作系统的 API ...

  7. 【翻译】使用Sencha Touch开发Google Glass应用程序

    原文:Developing for Google Glass with Sencha Touch 作者:Ross Gerbasi Ross Gerbasi is a Senior Engineer a ...

  8. Salesforce 官方扫盲自学导航

    Force.com Platform Fundamentals(新手入门的葵花宝典)www.salesforce.com/us/developer/docs/fundamentals/index_Le ...

  9. Erlang Rebar 使用指南之三:Rebar和OTP程序约定和命令

    Erlang Rebar 使用指南之三:Rebar和OTP程序约定和命令 全文目录: https://github.com/rebar/rebar/wiki 本章位置: https://github. ...

  10. unity连接photon服务端模块

    using UnityEngine; using System.Collections; using System; public class PhotonConnection : Photon.Mo ...