Skip to content

Latest commit

 

History

History
357 lines (249 loc) · 14.5 KB

File metadata and controls

357 lines (249 loc) · 14.5 KB

Python100example

内含100例python实例,全为自己编写,在python3.5环境下调试通过

示例: 主入口:com.python100.example.main.Main.py

如若调试哪一个示例,只需在Main.py打开对应示例的注释即可。

1.题目:有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少
 实现类:com.python100.example.files.Example1

2.企业发放的奖金根据利润提成。
    利润(I)低于或等于10万元时,奖金可提10%;
    利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;
    20万到40万之间时,高于20万元的部分,可提成5%;
    40万到60万之间时高于40万元的部分,可提成3%;
    60万到100万之间时,高于60万元的部分,可提成1.5%,
    高于100万元时,超过100万元的部分按1%提成,
    从键盘输入当月利润I,求应发放奖金总数?
实现类:  com.python100.example.files.Example2

3.一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
实现类:  com.python100.example.files.Example3

4.输入某年某月某日,判断这一天是这一年的第几天?
实现类:  com.python100.example.files.Example4

5.输入三个整数x,y,z,请把这三个数由小到大输出
实现类:  com.python100.example.files.Example5

6.斐波那契数列:0、1、1、2、3、5、8、13、21、34...输出
实现类:  com.python100.example.files.Example6

7.将一个列表的数据复制到另一个列表中
实现类:  com.python100.example.files.Example7

8.输出 9*9 乘法口诀表
实现类:  com.python100.example.files.Example8

9.暂停一秒输出。
实现类:  com.python100.example.files.Example9

10.暂停一秒输出,并格式化当前时间
实现类:  com.python100.example.files.Example10

11.古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,
    小兔子长到第三个月后每个月又生一对兔子,
    假如兔子都不死,问每个月的兔子总数为多少?
实现类:  com.python100.example.files.Example11

12.判断101-200之间有多少个素数,并输出所有素数
实现类:  com.python100.example.files.Example12

13.打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,
    其各位数字立方和等于该数本身。
    例如:153是一个"水仙花数",
    因为153=1的三次方+5的三次方+3的三次方
    实现类:  com.python100.example.files.Example13

14.将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5
实现类:  com.python100.example.files.Example14

15.利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示
实现类:  com.python100.example.files.Example15

16.输出指定格式的日期
实现类:  com.python100.example.files.Example16

17.输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
实现类:  com.python100.example.files.Example17

18.求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。
    例如2+22+222+2222+22222(此时共有5个数相加),
    几个数相加由键盘控制。
实现类:  com.python100.example.files.Example18

19.一个数如果恰好等于它的因子之和,这个数就称为"完数"。例如6=1+2+3.编程找出1000以内的所有完数。
实现类:  com.python100.example.files.Example19

20.一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
实现类:  com.python100.example.files.Example20

21.猴子吃桃问题:猴子第一天摘下若干个桃子,
当即吃了一半,还不瘾,又多吃了一个第二天早
上又将剩下的桃子吃掉一半,又多吃了一个。
以后每天早上都吃了前一天剩下的一半零一个。
到第10天早上想再吃时,见只剩下一个桃子了。
求第一天共摘了多少
实现类:  com.python100.example.files.Example21

22.两个乒乓球队进行比赛,各出三人。
甲队为a,b,c三人,乙队为x,y,z三人。
已抽签决定比赛名单。有人向队员打听
比赛的名单。a说他不和x比,c说他不
和x,z比,请编程序找出三队赛手的名单
实现类:  com.python100.example.files.Example22

23.打印出如下图案(菱形):
   *
  ***
 *****
*******
 *****
  ***
   *
   实现类:  com.python100.example.files.Example23

24.有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和。
实现类:  com.python100.example.files.Example24

25.求1+2!+3!+...+20!的和
实现类:  com.python100.example.files.Example25

26.利用递归方法求5!
实现类:  com.python100.example.files.Example26

27.利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。
实现类:  com.python100.example.files.Example27

28.5个人坐在一起,问第五个人多少岁?
他说比第4个人大2岁。问第4个人岁数,
他说比第3个人大2岁。问第三个人,
又说比第2人大两岁。问第2个人,
说比第一个人大两岁。最后问第一个人,
他说是10岁。请问第五个人多大?
实现类:  com.python100.example.files.Example28

29.给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字
实现类:  com.python100.example.files.Example29

30.一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。
实现类:  com.python100.example.files.Example30

31.输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母
实现类:  com.python100.example.files.Example31

32.按相反的顺序输出列表的值
 实现类:  com.python100.example.files.Example32

33.按逗号分隔列表
 实现类:  com.python100.example.files.Example33

34.练习函数调用。
 实现类:  com.python100.example.files.Example34

35.文本颜色设置
 实现类:  com.python100.example.files.Example35

36.求100之内的素数。
 实现类:  com.python100.example.files.Example36

37.对10个数进行排序
 实现类:  com.python100.example.files.Example37

38.求一个3*3矩阵主对角线元素之和
 实现类:  com.python100.example.files.Example38

39.有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中
 实现类:  com.python100.example.files.Example39

40.将一个数组逆序输出
 实现类:  com.python100.example.files.Example40

41.模仿静态变量的用法
实现类:  com.python100.example.files.Example41

42.学习使用auto定义变量的用法
实现类:  com.python100.example.files.Example42

43.模仿静态变量(static)另一案例。
实现类:  com.python100.example.files.Example43

44.两个 3 行 3 列的矩阵,实现其对应位置的数据相加,并返回一个新矩阵
实现类:  com.python100.example.files.Example44

45.统计 1 到 100 之和
实现类:  com.python100.example.files.Example45

46.求输入数字的平方,如果平方运算后小于 50 则退出
实现类:  com.python100.example.files.Example46

47.两个变量值互换。
实现类:  com.python100.example.files.Example47

48.数字比较
实现类:  com.python100.example.files.Example48

49.使用lambda来创建匿名函数
实现类:  com.python100.example.files.Example49

50.输出一个随机数。
实现类:  com.python100.example.files.Example50

51.学习使用按位与 & 
实现类:  com.python100.example.files.Example51

52.学习使用按位或 | 
实现类:  com.python100.example.files.Example52

53.学习使用按位异或 ^
实现类:  com.python100.example.files.Example53

54.取一个整数a从右端开始的4〜7位
实现类:  com.python100.example.files.Example54

55.学习使用按位取反~
实现类:  com.python100.example.files.Example55

56.画图,学用circle画圆形
实现类:  com.python100.example.files.Example56

57.画图,学用line画直线
实现类:  com.python100.example.files.Example57

58.画图,学用rectangle画方形
实现类:  com.python100.example.files.Example58

59.画图,综合例子
实现类:  com.python100.example.files.Example59

60.计算字符串长度
实现类:  com.python100.example.files.Example60

61.打印出杨辉三角形(要求打印出10行如下图)
实现类:  com.python100.example.files.Example61

62.查找字符串
实现类:  com.python100.example.files.Example62

63.省略

64.省略

65.省略

66.输入3个数a,b,c,按大小顺序输出。
实现类:  com.python100.example.files.Example66

67.输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组
实现类:  com.python100.example.files.Example67

68.有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面的m个数
实现类:  com.python100.example.files.Example68

69.有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来第几号的那位。
实现类:  com.python100.example.files.Example69

70.写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。
实现类:  com.python100.example.files.Example70

71.编写input()和output()函数输入,输出5个学生的数据记录
实现类:  com.python100.example.files.Example72

72.创建一个链表
实现类:  com.python100.example.files.Example73

73.反向输出一个链表
实现类:  com.python100.example.files.Example74

74.列表排序及连接
实现类:  com.python100.example.files.Example75

75.放松一下,算一道简单的题目
实现类:  com.python100.example.files.Example76

76.编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n
实现类:  com.python100.example.files.Example77

77.循环输出列表
实现类:  com.python100.example.files.Example77

78.找到年龄最大的人,并输出。请找出程序中有什么问题。
实现类:  com.python100.example.files.Example78

79.字符串排序
实现类:  com.python100.example.files.Example79

80.海滩上有一堆桃子,五只猴子来分。
第一只猴子把这堆桃子平均分为五份,
多了一个,这只猴子把多的一个扔入海中,
拿走了一份。第二只猴子把剩下的桃子又平均
分成五份,又多了一个,它同样把多的一个扔入
海中,拿走了一份,第三、第四、第五只猴子都
是这样做的,问海滩上原来最少有多少个桃子?
实现类:  com.python100.example.files.Example80

81.809*??=800*??+9*?? 其中??代表的两位数,
809*??为四位数,8*??的结果为两位数,9*??的
结果为3位数。求??代表的两位数,及809*??后的结果。
实现类:  com.python100.example.files.Example81

82.八进制转换为十进制
实现类:  com.python100.example.files.Example82

83.求0—7所能组成的奇数个数
实现类:  com.python100.example.files.Example83

84.连接字符串。
实现类:  com.python100.example.files.Example84

85.输入一个奇数,然后判断最少几个 9 除于该数的结果为整数
实现类:  com.python100.example.files.Example85

86.两个字符串连接程序
实现类:  com.python100.example.files.Example86

87.回答结果(结构体变量传递)
实现类:  com.python100.example.files.Example87

88.读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*
实现类:  com.python100.example.files.Example88

89.某个公司采用公用电话传递数据,数据
是四位的整数,在传递过程中是加密的,加
密规则如下:每位数字都加上5,然后用和除
以10的余数代替该数字,再将第一位和第四
位交换,第二位和第三位交换。
实现类:  com.python100.example.files.Example89

90.列表使用实例
实现类:  com.python100.example.files.Example90

91.时间函数举例1
实现类:  com.python100.example.files.Example91

92.时间函数举例2
实现类:  com.python100.example.files.Example92

93.时间函数举例3
实现类:  com.python100.example.files.Example93

94.时间函数举例4,一个猜数游戏,判断一个人反应快慢
实现类:  com.python100.example.files.Example94

95.字符串日期转换为易读的日期格式
实现类:  com.python100.example.files.Example95

96.计算字符串中子串出现的次数
实现类:  com.python100.example.files.Example96

97.从键盘输入一些字符,逐个把它们写到磁盘文件上,直到输入一个 # 为止
实现类:  com.python100.example.files.Example97

98.从键盘输入一个字符串,将小写字母全部转换成大写字母,然后输出到一个磁盘文件"test"中保存
实现类:  com.python100.example.files.Example98

99.有两个磁盘文件A和B,各存放一行字母,要求把这两个文件中的信息合并(按字母顺序排列), 输出到一个新文件C中
实现类:  com.python100.example.files.Example99

100.列表转换为字典
实现类:  com.python100.example.files.Example100