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

边栏推荐
- nodejs 安装多版本 版本切换
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- appium软件自动化测试框架
- nodejs install multi-version version switching
- Promise solves blocking synchronization and turns asynchronous into synchronous
- 可变字符串
- 【虚拟化生态平台】虚拟化平台esxi挂载USB硬盘
- initramfs详解----添加硬盘驱动并访问磁盘
- jmeter跨平台运行csv等文件
- How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
猜你喜欢

typescript55 - generic constraints

《Greenplum构建实时数据仓库实践》简介

- heavy OpenCV 】 【 mapping

Installation and configuration of nodejs+npm

安全至上:落地DevSecOps最佳实践你不得不知道的工具

TensoFlow学习记录(二):基础操作

2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"

this巩固训练,从两道执行题加深理解闭包与箭头函数中的this

【日志框架】

typescript58 - generic classes
随机推荐
Promise 解决阻塞式同步,将异步变为同步
typescript56 - generic interface
nodejs+express实现数据库mysql的访问,并展示数据到页面上
jmeter distributed stress test
KunlunBase 1.0 is released!
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
typescript52 - simplify generic function calls
typescript52-简化泛型函数调用
Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
静态文件快速建站
工程制图平面投影练习
How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
.NET Static Code Weaving - Rougamo Release 1.1.0
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
redis中常见的问题(缓存穿透,缓存雪崩,缓存击穿,redis淘汰策略)
MySQL回表指的是什么
[store mall project 01] environment preparation and testing
Flask Framework Beginner-05-Command Management Manager and Database Use
GraphQL背后处理及执行过程是什么
工程制图复习题(带答案)