惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
博客园 - 聂微东
小众软件
小众软件
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
TaoSecurity Blog
TaoSecurity Blog
博客园 - 司徒正美
罗磊的独立博客
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
S
Security @ Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
月光博客
月光博客
S
Secure Thoughts
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Forbes - Security
Forbes - Security
H
Heimdal Security Blog
W
WeLiveSecurity
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
L
LangChain Blog
T
The Blog of Author Tim Ferriss
NISL@THU
NISL@THU
Google DeepMind News
Google DeepMind News
Cloudbric
Cloudbric
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
博客园 - 三生石上(FineUI控件)
博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Project Zero
Project Zero
SecWiki News
SecWiki News
爱范儿
爱范儿
The Register - Security
The Register - Security
AI
AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
L
Lohrmann on Cybersecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
J
Java Code Geeks
S
Securelist
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog

博客园 - zzuCharles

Qwen-Max 8G 内存本地部署方案(轻量化可用版) MFC中使用多线程 高性能 Flink SQL 优化 Flink 时间概念 EventTime 和 Watermark SQL 优化(来源平时总结及网络分享) hadoop 查询优化 python 读取csv多编码兼容读取 文件拆分-python Mysql 调优笔记 Python 输出菱形 Python 读取目录,office文件分类 Mysql 字符串日期互转 MaxCompute 语句笔记 数据仓库架构 Python 比较两个字符串的相似度 Python print Python简单计算器 用户价值模型 CITE :https://www.jianshu.com/p/34199b13ffbc 用户生命周期模型
Python 猜数小程序(练习)
zzuCharles · 2020-05-11 · via 博客园 - zzuCharles
------Game1
def guess(armnums):
    number = random.randint(1, 9) 
    chances = 0  
    while chances < 5: 
        print("System guess :%d"%number)
        if armnums == number:  
            print("System   Get it !!!")
            break
        elif armnums < number: 
            print("System guess was too high  !") 
            number=random.randint(1, number) 
        else:  
            print("System guess was too low !") 
            number=random.randint(number, 9) 
        chances += 1 
    if not chances < 5: 
        print("System LOSE  YOU WIN !!!")
 
if __name__ == '__main__': 
    sysflag=True 
    while sysflag:
        arm=input("Please input a arm number (between 1 and 9):")
        guess(int(arm))
        flag=input("Continue Y/N ?:")        
        if flag.upper()=='N':
            print('Game over!')
            sysflag=False

------Game2
import random 
  

def guess(armnums):
    number = random.randint(1, 9) 
    chances = 0  
    while chances < 5: 
        print("System guess :%d"%number)
        if armnums == number:  
            print("System   Get it !!!")
            break
        elif armnums < number: 
            print("System guess was too high  !") 
            number=random.randint(armnums, number) 
        else:  
            print("System guess was too low !") 
            number=random.randint(number, armnums) 
        chances += 1   
 
if __name__ == '__main__': 
    sysflag=True 
    while sysflag:
        arm=input("Please input a arm number (between 1 and 9):")
        guess(int(arm))
        flag=input("Continue Y/N ?:")        
        if flag.upper()=='N':
            print('Game over!')
            sysflag=False


------Game3
import random 
  
def guess(armnums):
    list =[]
    number = random.randint(1, 1000)  
    fmax = 1000
    fmin = 1
    while True: 
        print("System guess :%d"%number)
        if armnums == number:  
            print("System   Get it !!!")
            break
        elif armnums < number: 
            print("System guess was too high  !") 
            fmax=number 
        else:  
            fmin=number
            print("System guess was too low !") 
        list.append(number) 
        number=random.randint(fmin,fmax) 
        if number in list:
            number=random.randint(fmin,fmax) 
 
if __name__ == '__main__': 
    sysflag=True 
    while sysflag:
        arm=input("Please input a arm number (between 1 and 1000):")
        guess(int(arm))
        flag=input("Continue Y/N ?:")        
        if flag.upper()=='N':
            print('Game over!')
            sysflag=False

脑子是空的不要紧,主要是不要进水······

posted @ 2020-05-11 19:51  zzuCharles  阅读(336)  评论()    收藏  举报