1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# 初级:
#
# 1.判断下面标识符是否合法并说明不合法的原因
# @abc.com 不合法
# 123ok 不合法
# _xiaoming 合法
# Xiaoming_$ 不合法
# interface 合法
# sina@163 不合法


# 2.从控制台输入圆的半径,计算周长和面积, π=3.14
# r = int(input("请输入半径:"))
# c = 2 * 3.14 * r
# s = 3.14 * r * r


# 3.一辆汽车以40km/h的速度行驶,行驶了45678.9km,求所用的时间
speed = 40
s = 45678.9
t = s/speed

# 4.华氏温度转摄氏温度
# 【提示:将华氏温度转换为摄氏温度(F是华氏温度) F = 1.8C + 32】
F = 200
C = (F - 32)/1.8

# 5.从控制台输入两个数,输出较大的值
# a = int(input("请输入a:"))
# b = int(input("请输入b:"))
# if a > b:
# print("最大值a是:", a)
# else:
# print("最大值b是:", b)


# 6.模拟玩骰子游戏,根据骰子点数决定什么惩罚【例如:1.跳舞,2.唱歌....】
import random
n = random.randint(1, 6) # 随机取1~6中的某一个整数
if n == 1:
print("跳舞")
elif n == 2:
print("唱歌")
elif n == 3:
print("喝酒")
elif n == 4:
print("再喝一杯")
elif n == 5:
print("再来一瓶")
else:
print("再来一打")


# 中级:
# 1.x 为 0-99 取一个数,y 为 0-199 取一个数,如果 x>y 则输出 x, 如果 x 等于 y 则输出 x+y,否则输出y
x = random.randint(0, 99)
y = random.randint(0, 199)
if x > y:
print(x)
elif x == y:
print(x+y)
else:
print(y)


# 2.从控制台输入三个数,输出较大的值
a = int(input("请输入a:"))
b = int(input("请输入b:"))
c = int(input("请输入c:"))
if a>b and a>c:
print("最大值a是:", a)
elif b>a and b>c:
print("最大值b是:", b)
elif c>a and c>b:
print("最大值c是:", c)


# 3.从控制台输入一个三位数,如果是水仙花数就打印“是水仙花数”,否则打印“不是水仙花数”
# 该数的每一位的立方和等于自身的值,比如:153=1^3+5^3+3^3
# 例如:153=1^3+5^3+3^3
# n = 153:
# 个位:n%10
# 十位:(n//10)%10
# 百位:n//100
n = int(input("请输入一个数:"))
if (n%10)**3 + ((n//10)%10)**3 + (n//100)**3 == n:
print(n, "是水仙花数")
else:
print(n, "不是水仙花数")


# 高级:
# 1.从控制台输入一个五位数,如果是回文数就打印“是回文数”,否则打印“不是回文数”
# 回文数: 对称的5位数
# 例如:11111 12321 12221
n = int(input('请输入一个五位数:'))
a = n // 10000
b = (n//1000) % 10
c = (n//10) % 10
d = n%10
if a==d and b==c:
print(n, "是回文数")
else:
print(n, "不是回文数")


# 预习内容:list、for循环
#

''''''
# x = (input())
# print(type(x))


print(100 - 25 * 3 % 4)
print(not [])
print(not {"name": "张三"})
if {"name": "张三"}:
print(1)

# 1,成绩判定
# 大于85 优秀
# 大于等于75小于等于85 良好
# 大于等于60小于75 及格
# 小于60 不及格
# score = int(input("请输入您的分数:"))
# if score > 85:
# print("优秀")
# elif score >= 75:
# print("良好")
# elif score >= 60:
# print("及格")
# else:
# print("不及格")


# 2,判断一个年份是闰年还是平年;
# (1.能被4整除而不能被100整除.(如2004年就是闰年,1800年不是.)
# 2.能被400整除.(如2000年是闰年))
# year = int(input('请输入一个年份:'))
# if (year%4==0 and year%100!=0) or year%400==0:
# print(year, "是闰年")
# else:
# print(year, "是平年")


# 3,输入一个月份,然后输出对应月份有多少天,将天数输出(不考虑闰年)
# 比如:
# 输入 6 输出为30
# 输入 2 输出为28
# month = int(input('请输入一个月份:'))
# if month == 2:
# print(28)
# # elif month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12:
# elif month in [1,3,5,7,8,10,12]:
# print(31)
# else:
# print(30)


# 4. 开发一款软件,根据公式(身高-108)*2=标准体重,可以有10斤左右的浮动。
# 来观察测试者体重是否合适, 输入真实身高(cm),真实体重(斤)
# height = int(input("请输入身高:"))
# weight = int(input('请输入体重:'))
# s_weight = (height - 108) * 2
#
# # if weight >= s_weight - 10 and weight <= s_weight + 10:
# if s_weight-10 <= weight <= s_weight+10:
# print("合适")
# else:
# print("不合适")


# 5, 入职薪水10K,每年涨幅入职薪水的5%,50年后工资多少?
salary = 10
s = salary + 0.05*salary*50
print(s)


# 6, 为抵抗洪水,战士连续作战89小时,编程计算共多少天零多少小时?
hours = 89
print(hours//24, "天,", hours%24, "小时")


# 7, 给定一个5位数,分别把这个数字的万位, 千位,百位、十位、个位算出来并显示。如: 34567
n = 34567
print(n//10000)
print((n//1000)%10)
print((n//100)%10)
print((n//10)%10)
print(n%10)


# 8.分别输入某年某月某日,判断这一天是这一年的第几天?(考虑闰年) (*****)
# year, month, day
# 提示: 使用多个if单分支
year = int(input("请输入year:"))
month = int(input("请输入month:"))
day = int(input("请输入day:"))
# 2020,11,22
days = day
if month > 1:
days = days + 31
if month > 2:
if (year%4==0 and year%100!=0) or year%400==0:
days += 29
else:
days += 28
if month > 3:
days += 31
if month > 4:
days += 30
if month > 5:
days += 31
if month > 6:
days += 30
if month > 7:
days += 31
if month > 8:
days += 31
if month > 9:
days += 30
if month > 10:
days += 31
if month > 11:
days += 30

print(days)


# 9,输入一个时间,输出该时间的下一秒: (*****)
# 如:23:59:59,
# 输入:hour, min, sec
# 输出 0: 0: 0
hour = int(input("hour:"))
min = int(input("min:"))
sec = int(input("sec:"))

sec += 1
if sec == 60:
sec = 0
min += 1

if min == 60:
min = 0
hour += 1

if hour == 24:
hour = 0

print("%d:%d:%d"%(hour, min, sec))
print("{}:{}:{}".format(hour, min, sec))
print(f"{hour}:{min}:{sec}")