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

推荐订阅源

GbyAI
GbyAI
Simon Willison's Weblog
Simon Willison's Weblog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
Last Week in AI
Last Week in AI
月光博客
月光博客
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
U
Unit 42
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
H
Hacker News: Front Page
Recent Announcements
Recent Announcements
C
CXSECURITY Database RSS Feed - CXSecurity.com
Latest news
Latest news
小众软件
小众软件
P
Palo Alto Networks Blog
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
S
Secure Thoughts
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
O
OpenAI News
S
Securelist
云风的 BLOG
云风的 BLOG
H
Help Net Security
T
Troy Hunt's 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)  评论()    收藏  举报