当前位置:网站首页>实例036:算素数
实例036:算素数
2022-08-04 01:35:00 【懒笑翻】
题目:求100之内的素数。
程序分析:用else执行for循环的奖励代码(如果for是正常完结,非break)。
代码:
lo = int(input('下限:'))
hi = int(input('上限:'))
for i in range(lo, hi + 1):
if i > 1:
for j in range(2, i):
if (i % j) == 0:
break
else:
print(i, end=' ')
"""
* @Author: xiaofang
* @Description:
学习中遇到问题没人解答?小编创建了一个Python学习交流QQ群,扫码下方QQ群二维码即可
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
"""
结果:
边栏推荐
- jmeter分布式压测
- Electronics manufacturing enterprise deployment WMS what are the benefits of warehouse management system
- Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
- Promise 解决阻塞式同步,将异步变为同步
- 快速入门EasyX图形编程
- typescript50 - type specification between cross types and interfaces
- Web APIs BOM- 操作浏览器:swiper 插件
- js中常用的几种遍历处理数据的方法梳理
- 通用的测试用例编写大全(登录测试/web测试等)
- 数组_滑动窗口 | leecode刷题笔记
猜你喜欢
[store mall project 01] environment preparation and testing
Flask Framework Beginner-05-Command Management Manager and Database Use
持续投入商品研发,叮咚买菜赢在了供应链投入上
静态文件快速建站
2022年上半年各大厂Android面试题整理及答案解析(持续更新中......)
Android interview questions and answer analysis of major factories in the first half of 2022 (continuously updated...)
nodejs+express实现数据库mysql的访问,并展示数据到页面上
【日志框架】
typescript52-简化泛型函数调用
观察者模式
随机推荐
How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
typescript50-交叉类型和接口之间的类型说明
工程制图复习题
谁说程序员不懂浪漫,表白代码来啦~
Vant3 - click on the corresponding name name to jump to the next page corresponding to the location of the name of the TAB bar
GNSS文章汇总
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
在Activity中获取另一个XML文件的控件
this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
字符串的排列
数组_滑动窗口 | leecode刷题笔记
[store mall project 01] environment preparation and testing
Android interview questions and answer analysis of major factories in the first half of 2022 (continuously updated...)
工程制图复习题(带答案)
jmeter分布式压测
Web APIs BOM- 操作浏览器:swiper 插件
esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
持续投入商品研发,叮咚买菜赢在了供应链投入上
IDEA02:配置SQL Server2019数据库