Python基础练习100题 ( 1~ 10)

一套全面的练习,大家智慧的结晶

大家好,好久不见,我最近在Github上发现了一个好东西,是关于夯实Python基础的100道题,原作者是在Python2的时候创建的,闲来无事,非常适合像我一样的小白来练习

对于每一道题,解法都不唯一,我在这里仅仅是抛砖引玉,希望可以集合大家的智慧,如果哪道题有其他解法,希望可以在评论中留下大家宝贵的意见!每次我会更新10道题,一共会更新10篇,这也算是对我之前的文章一个总结啦,如果没有看到我之前有关Python的小白学习分享的同学们,可以戳下面连接查看哈:

如果大家想要和我联系,可以访问我的个人主页:

好啦,闲话少说,让我们开始今天的刷题之旅吧!

Question 1:

Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-separated sequence on a single line.

解法一

for i in range(2000,3201):
    if i%7 == 0 and i%5!=0:
        print(i,end=',')
print("\b")

解法二

numbers = [str(x) for x in range(2000,3201) if (x%7==0) and (x%5!=0)]
print (','.join(numbers))

Question 2:

* Write a program which can compute the factorial of a given numbers.The results should be printed in a comma-separated sequence on a single line.Suppose the following input is supplied to t

  • 10
    点赞
  • 142
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值