当前位置: 首页 > news >正文

b2c网站有哪些平台热点新闻事件及评论

b2c网站有哪些平台,热点新闻事件及评论,淘宝做导航网站,张家界做网站目录 1、用循环语句求122333444455555的和 2、求出2000-2100的所有闰年,条件是四年一闰,百年不闰,四百年再闰 3、输入两个正整数,并求出它们的最大公约数和最小公倍数 4、求出100以内的所有质数 5、求100以内最大的10个质数的…

目录

1、用循环语句求1+22+333+4444+55555的和

 2、求出2000-2100的所有闰年,条件是四年一闰,百年不闰,四百年再闰

3、输入两个正整数,并求出它们的最大公约数和最小公倍数

4、求出100以内的所有质数

5、求100以内最大的10个质数的和

6、求1到10所有的偶数和

7、将10-20不能被2或3整除的数输出


1、用循环语句求1+22+333+4444+55555的和

for i in range(1,6):a = str(i)lst.append(a)
for j in range(0,5):b = int(lst[j] * (j + 1))sum += b
print("sum = ",sum)

运行结果:

F:\pythonProject\venv\Scripts\python.exe F:\pythonProject\yunjisuan\0719homework\04.py 
sum =  60355Process finished with exit code 0

 2、求出2000-2100的所有闰年,条件是四年一闰,百年不闰,四百年再闰

lst = []
for i in range(2000,2101):if i%4 == 0 and i%100 != 0 or i%400 == 0:lst.append(i)
print(lst)

运行结果:

F:\pythonProject\venv\Scripts\python.exe F:\pythonProject\yunjisuan\0719homework\05.py 
[2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056, 2060, 2064, 2068, 2072, 2076, 2080, 2084, 2088, 2092, 2096]Process finished with exit code 0

3、输入两个正整数,并求出它们的最大公约数和最小公倍数

a = int(input("请输入第一个整数:"))
b = int(input("请输入第二个整数:"))
if a > b:a , b = b , a
for i in range(a,0,-1):if a % i == 0 and b % i == 0:print("%d和%d的最大公约数是%d"%(a , b , i))print("%d和%d的最小公倍数是%d"%(a , b , a * b / i))break

运行结果:

F:\pythonProject\venv\Scripts\python.exe F:\pythonProject\yunjisuan\0719homework\06.py 
请输入第一个整数:20
请输入第二个整数:26
20和26的最大公约数是2
20和26的最小公倍数是260Process finished with exit code 0

4、求出100以内的所有质数

lst = []
flag = True
for i in range(2,101):for j in range(2,i):if i % j == 0:flag = Falsebreakelse:flag = Trueif flag == True:lst.append(i)
print(lst)

运行结果:

F:\pythonProject\venv\Scripts\python.exe F:\pythonProject\yunjisuan\0719homework\07.py 
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]Process finished with exit code 0

5、求100以内最大的10个质数的和

flag =True
sum = 0
cnt = 0
for i in range(100,1,-1):for j in range(2,i):if i % j == 0:flag = Falsebreakelse:flag = Trueif flag == True:sum += icnt += 1if cnt == 10:print("100以内最大的10个质数的和为:",sum)break

运行结果:

F:\pythonProject\venv\Scripts\python.exe F:\pythonProject\yunjisuan\0719homework\08.py 
100以内最大的10个质数的和为: 732Process finished with exit code 0

6、求1到10所有的偶数和

sum = 0
for i in range(1,11):if i % 2 == 0:sum += i
print("1到10所有的偶数和为:",sum)

运行结果:

F:\pythonProject\venv\Scripts\python.exe F:\pythonProject\yunjisuan\0719homework\09.py 
1到10所有的偶数和为: 30Process finished with exit code 0

7、将10-20不能被2或3整除的数输出

for i in range(10,21):if i % 2 != 0 and i % 3 != 0:print(i)

运行结果:

F:\pythonProject\venv\Scripts\python.exe F:\pythonProject\yunjisuan\0719homework\10.py 
11
13
17
19Process finished with exit code 0

http://www.tj-hxxt.cn/news/56268.html

相关文章:

  • 珠三角做网站太原seo快速排名怎么样
  • 网上找客户有哪些网站网站优化外包找谁
  • java 政府网站开发网络广告推广方案
  • 做外贸的经常浏览的三个网站合肥seo公司
  • 肇庆网站快速排名优化长沙网站建设
  • 西安 餐饮 网站建设品牌推广文案
  • 国家职业资格证书网站厦门关键词排名seo
  • 厦门英文网站建设广东东莞疫情最新消息
  • 网页设计实验报告3000字批量优化网站软件
  • 三只松鼠网站建设中国舆情观察网
  • 推荐聊城做网站的公司在百度上打广告找谁推广产品
  • 做网站软件j电商seo是什么意思
  • 安居网站建设广告sem是什么意思
  • 做网站怎么设置会员html网页制作步骤
  • 专门做网站制作的公司郑州网站顾问
  • 网站定制文章列表项怎么做南宁网站公司
  • 新闻做的差的网站镇江seo优化
  • 上街做网站seo在中国
  • 网站建设数据库是什么网站建设公司官网
  • css 手机网站字体重叠seo博客网址
  • 论坛网站制作费用北京疫情最新情况
  • 长春哪家做网站便宜徐州seo网站推广
  • 做二手的网站有哪些网络营销推广方案案例
  • 做商城网站哪里好舆情网站直接打开怎么弄
  • 附近做网站的公司竞价推广员月挣多少
  • 自己做的网站如何连接入数据库台州优化排名推广
  • wordpress支持手机适应优化百度百科
  • 公司以前做的免费网站太多 新网站搜索不到百度竞价排名公司
  • 静安集团网站建设市场调研报告范文大全
  • 宁波哪里做网站的营销型企业网站制作