当前位置:网站首页>实例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电子书!
"""
结果:
边栏推荐
- [store mall project 01] environment preparation and testing
- DDTL:远距离的域迁移学习
- 网页三维虚拟展厅为接入元宇宙平台做基础
- GNSS文章汇总
- nodejs+express realizes the access to the database mysql and displays the data on the page
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- C 学生管理系统_分析
- 字符串的排列
- 【Untitled】
- 2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"
猜你喜欢
【store商城项目01】环境准备以及测试
Electronics manufacturing enterprise deployment WMS what are the benefits of warehouse management system
nodejs+express实现数据库mysql的访问,并展示数据到页面上
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
The 600MHz band is here, will it be the new golden band?
持续投入商品研发,叮咚买菜赢在了供应链投入上
工程制图平面投影练习
Array_Sliding window | leecode brushing notes
MongoDB数据接入实践
HBuilderX的下载安装和创建/运行项目
随机推荐
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"
nodejs切换版本使用(不需要卸载重装)
C # WPF equipment monitoring software (classic) - the next
字符串的排列
Google Earth Engine - Calculates the effective width of rivers using publicly available river data
Intranet penetration - application
工程制图复习题
Slipper —— 虚点,最短路
pygame 中的transform模块
Is there any jdbc link to Youxuan database documentation and examples?
nodejs 安装多版本 版本切换
Web APIs BOM- 操作浏览器:swiper 插件
MySQL回表指的是什么
.NET Static Code Weaving - Rougamo Release 1.1.0
MongoDB数据接入实践
FeatureNotFound( bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requested:
如何通过API接口从淘宝(或天猫店)复制宝贝到拼多多接口代码对接教程
Apache DolphinScheduler actual combat task scheduling platform - a new generation of distributed workflow
typescript53 - generic constraints