当前位置:网站首页>输入三次猜一个数字
输入三次猜一个数字
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可以运用到生活中,比如说:中奖、用户输入等。
边栏推荐
- Responsive MySQL of vertx
- 截图工具Snipaste
- Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
- Lucene merge document order
- Leetcode 213: 打家劫舍 II
- Application of pigeon nest principle in Lucene minshouldmatchsumscorer
- Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
- Vertx multi vertical shared data
- VMware network mode - bridge, host only, NAT network
- 技术干货|昇思MindSpore Lite1.5 特性发布,带来全新端侧AI体验
猜你喜欢

Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing

Leetcode 213: 打家劫舍 II

VMWare网络模式-桥接,Host-Only,NAT网络

HCIA notes

Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction

技术干货|昇思MindSpore NLP模型迁移之Roberta ——情感分析任务

Use of other streams

技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建

PAT甲级 1030 Travel Plan

Technical dry goods Shengsi mindspire operator parallel + heterogeneous parallel, enabling 32 card training 242 billion parameter model
随机推荐
技术干货 | AlphaFold/ RoseTTAFold开源复现(2)—AlphaFold流程分析和训练构建
Longest common prefix and
Comparison of advantages and disadvantages between most complete SQL and NoSQL
Technical dry goods Shengsi mindspire lite1.5 feature release, bringing a new end-to-end AI experience
Hello world of vertx
PAT甲级 1028 List Sorting
The embodiment of generics in inheritance and wildcards
技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
PAT甲级 1032 Sharing
Rabbit MQ message sending of vertx
[set theory] order relation (partial order relation | partial order set | example of partial order set)
List exercises after class
Introduction of buffer flow
Wireshark software usage
昇思MindSpore再升级,深度科学计算的极致创新
Leetcode 198: 打家劫舍
Lucene introduces NFA
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
HCIA notes
基于RNA的新型癌症疗法介绍