【Python编程基础练习】 Python编程基础练习100题学习记录第一期(1~10) ...

打印 上一主题 下一主题

主题 518|帖子 518|积分 1554

1.此为GitHub项目的学习记录,记录着我的思考,代码基本都有注释。
2.可以作为Python初学者巩固基础的绝佳练习,原题有些不妥的地方我也做了一些修正。
3.建议大家进行Python编程时使用英语,工作时基本用英语。
4.6~17题为level1难度,18-22题为level3难度,其余都为level1难度。
项目名称:
100+ Python challenging programming exercises for Python 3


  1. #!usr/bin/env Python3.9     # linux环境运行必须写上
  2. # -*- coding:UTF-8 -*-      # 写一个特殊的注释来表明Python源代码文件是unicode格式的
  3. """Question:
  4.     Write a program which will find all such numbers
  5.     which are divisible by 7 but are not a multiple of 5,
  6.     between 2000 and 3200 (both included).
  7.     The numbers obtained should be printed
  8.     in a comma-separated sequence on a single line."""
  9. '''Hints: Consider use range(#begin, #end) method'''
  10. l1 = []  # 建立空列表
  11. for i in range(2000, 3201):     # for循环寻找能被7整除但不能被5整除的数字
  12.     if (i % 7 == 0) and (i % 5 != 0):
  13.         l1.append(str(i))       # 列表里的数据需要是字符串
  14. print(','.join(l1))             # 在一行显示,以逗号隔开
复制代码


[code]#!usr/bin/env Python3.9# -*- coding:UTF-8 -*-"""Question: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 the program: 8 Then, the output should be: 40320"""'''Hints: In case of input data being supplied to the question, it should be assumed to be a console input.'''i = 1result = 1t = int(input('请输入一个数字: '))while i
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

南飓风

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表