当前位置:网站首页>输入三次猜一个数字
输入三次猜一个数字
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可以运用到生活中,比如说:中奖、用户输入等。
边栏推荐
- VMware virtual machine installation
- List exercises after class
- Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
- Use of file class
- Understanding of class
- 技术干货|昇思MindSpore可变序列长度的动态Transformer已发布!
- 为什么说数据服务化是下一代数据中台的方向?
- 【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
- Hello world of vertx
- 昇思MindSpore再升级,深度科学计算的极致创新
猜你喜欢
随机推荐
【CoppeliaSim4.3】C#调用 remoteApi控制场景中UR5
技术干货|百行代码写BERT,昇思MindSpore能力大赏
Jeecg data button permission settings
Common architectures of IO streams
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
技术干货 | AlphaFold/ RoseTTAFold开源复现(2)—AlphaFold流程分析和训练构建
Arduino 软串口通信 的几点体会
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
Topic | synchronous asynchronous
Technical dry goods | hundred lines of code to write Bert, Shengsi mindspire ability reward
论文学习——鄱阳湖星子站水位时间序列相似度研究
为什么说数据服务化是下一代数据中台的方向?
Longest common prefix and
Traversal in Lucene
Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
Inverted chain disk storage in Lucene (pfordelta)
PAT甲级 1028 List Sorting
項目經驗分享:實現一個昇思MindSpore 圖層 IR 融合優化 pass
VMware network mode - bridge, host only, NAT network








