ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【Python编程基础练习】 Python编程基础练习100题学习记录第一期(1~10) [打印本页]

作者: 九天猎人    时间: 2022-9-3 01:18
标题: 【Python编程基础练习】 Python编程基础练习100题学习记录第一期(1~10)
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




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4