当前位置:网站首页>输入三次猜一个数字
输入三次猜一个数字
2022-07-03 07:36:00 【算法与编程之美】
1引言
设置一个可以输入三次的系统,用户可以在三次之内猜一个设置好的数字。
2 问题描述
输入一个数字n,用户可以在三次之内猜这个数字。
示例:
输入:n=5
输入第一次:n=2
输出:“猜测错误”
输入第二次:n=5
输出:“猜测正确”
break
3 实验结果与讨论
通过实验、实践等证明提出的方法是有效的,是能够解决开头提出的问题。
代码清单 1
n=int(input('请输入一个数字:')) for i in range(3): a=int(input('请输入您猜测的数字:')) if(a==n): print('您的猜测正确') break else: print('您猜测有误') |
4 结语
在for循环之下,设定需要循环的次数,让我们的python可以运用到生活中,比如说:中奖、用户输入等。
边栏推荐
- Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
- Introduction of transformation flow
- 技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
- Robots protocol
- Warehouse database fields_ Summary of SQL problems in kingbase8 migration of Jincang database
- The difference between typescript let and VaR
- Common architectures of IO streams
- Lucene hnsw merge optimization
- Visit Google homepage to display this page, which cannot be displayed
- Industrial resilience
猜你喜欢
Common methods of file class
【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结
Arduino Serial系列函数 有关print read 的总结
技术干货|百行代码写BERT,昇思MindSpore能力大赏
Topic | synchronous asynchronous
TreeMap
Application of pigeon nest principle in Lucene minshouldmatchsumscorer
Take you through the whole process and comprehensively understand the software accidents that belong to testing
Understanding of class
Technology dry goods | luxe model for the migration of mindspore NLP model -- reading comprehension task
随机推荐
Vertx's responsive MySQL template
OSI knowledge sorting
Take you through the whole process and comprehensively understand the software accidents that belong to testing
Spa single page application
Hisat2 - stringtie - deseq2 pipeline for bulk RNA seq
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
技术干货|昇思MindSpore初级课程上线:从基本概念到实操,1小时上手!
HCIA notes
The embodiment of generics in inheritance and wildcards
JUnit unit test of vertx
Hello world of vertx
Lucene hnsw merge optimization
SQL create temporary table
Traversal in Lucene
技术干货|昇思MindSpore Lite1.5 特性发布,带来全新端侧AI体验
Visit Google homepage to display this page, which cannot be displayed
Hnsw introduction and some reference articles in lucene9
项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass
Image recognition and detection -- Notes
Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function