当前位置:网站首页>实例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电子书!
"""结果:

边栏推荐
- 有没有jdbc 链接优炫数据库文档及示例?
- Google Earth Engine - Calculates the effective width of rivers using publicly available river data
- 通用的测试用例编写大全(登录测试/web测试等)
- MongoDB数据接入实践
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- lombok注解@RequiredArgsConstructor的使用
- appium软件自动化测试框架
- idea中diagram使用
- jmeter分布式压测
- Promise 解决阻塞式同步,将异步变为同步
猜你喜欢

typescript48 - type compatibility between functions

initramfs详解----添加硬盘驱动并访问磁盘

typescript48-函数之间的类型兼容性

谁说程序员不懂浪漫,表白代码来啦~

一个注解替换synchronized关键字:分布式场景下实现方法加锁

特征值与特征向量

Demand analysis of MES management system in electronic assembly industry

Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析

静态/动态代理模式

企业虚拟偶像产生了实质性的价值效益
随机推荐
GNSS【0】- 专题
工程制图复习题
内网穿透-应用
- heavy OpenCV 】 【 mapping
jmeter distributed stress test
nodejs+express realizes the access to the database mysql and displays the data on the page
如何通过API接口从淘宝(或天猫店)复制宝贝到拼多多接口代码对接教程
循环绕过问题
The 600MHz band is here, will it be the new golden band?
持续投入商品研发,叮咚买菜赢在了供应链投入上
HBuilderX的下载安装和创建/运行项目
Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析
C语言:学生管理系统(链表版)
esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)
html select标签赋值数据库查询结果
持续投入商品研发,叮咚买菜赢在了供应链投入上
【日志框架】
typescript48 - type compatibility between functions
虚拟机CentOS7中无图形界面安装Oracle
【OpenCV】-重映射