bai-python-hwc 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bai_python_hwc/__init__.py +46 -0
- bai_python_hwc/answers/hwc101.py +38 -0
- bai_python_hwc/answers/hwc103.py +52 -0
- bai_python_hwc/answers/hwc104.py +45 -0
- bai_python_hwc/answers/hwc105.py +45 -0
- bai_python_hwc/answers/hwc106.py +56 -0
- bai_python_hwc/answers/hwc107.py +49 -0
- bai_python_hwc/answers/hwc108.py +45 -0
- bai_python_hwc/answers/hwc109.py +50 -0
- bai_python_hwc/answers/hwc110.py +42 -0
- bai_python_hwc/answers/hwc111.py +47 -0
- bai_python_hwc/answers/hwc112.py +42 -0
- bai_python_hwc/answers/hwc113.py +58 -0
- bai_python_hwc/answers/hwc114.py +58 -0
- bai_python_hwc/answers/hwc115.py +38 -0
- bai_python_hwc/answers/hwc116.py +44 -0
- bai_python_hwc/answers/hwc117.py +46 -0
- bai_python_hwc/answers/hwc118.py +47 -0
- bai_python_hwc/answers/hwc119.py +44 -0
- bai_python_hwc/answers/hwc120.py +41 -0
- bai_python_hwc/answers/hwc121.py +50 -0
- bai_python_hwc/answers/hwc122.py +54 -0
- bai_python_hwc/answers/hwc123.py +43 -0
- bai_python_hwc/answers/hwc124.py +41 -0
- bai_python_hwc/answers/hwc125.py +52 -0
- bai_python_hwc/answers/hwc126.py +40 -0
- bai_python_hwc/answers/hwc127.py +41 -0
- bai_python_hwc/answers/hwc128.py +39 -0
- bai_python_hwc/answers/hwc130.py +46 -0
- bai_python_hwc/answers/hwc131.py +46 -0
- bai_python_hwc/answers/hwc132.py +38 -0
- bai_python_hwc/answers/hwc133.py +61 -0
- bai_python_hwc/answers/hwc134.py +45 -0
- bai_python_hwc/answers/hwc135.py +49 -0
- bai_python_hwc/answers/hwc136.py +43 -0
- bai_python_hwc/answers/hwc201.py +47 -0
- bai_python_hwc/answers/hwc202.py +47 -0
- bai_python_hwc/answers/hwc203.py +48 -0
- bai_python_hwc/answers/hwc204.py +61 -0
- bai_python_hwc/answers/hwc205.py +56 -0
- bai_python_hwc/answers/hwc206.py +53 -0
- bai_python_hwc/answers/hwc207.py +43 -0
- bai_python_hwc/answers/hwc208.py +57 -0
- bai_python_hwc/answers/hwc209.py +42 -0
- bai_python_hwc/answers/hwc210.py +46 -0
- bai_python_hwc/answers/hwc211.py +62 -0
- bai_python_hwc/answers/hwc212.py +58 -0
- bai_python_hwc/answers/hwc213.py +54 -0
- bai_python_hwc/answers/hwc214.py +55 -0
- bai_python_hwc/answers/hwc215.py +53 -0
- bai_python_hwc/answers/hwc216.py +50 -0
- bai_python_hwc/answers/hwc217.py +38 -0
- bai_python_hwc/answers/hwc218.py +44 -0
- bai_python_hwc/answers/hwc219.py +49 -0
- bai_python_hwc/answers/hwc220.py +58 -0
- bai_python_hwc/answers/hwc221.py +49 -0
- bai_python_hwc/answers/hwc222.py +48 -0
- bai_python_hwc/answers/hwc223.py +39 -0
- bai_python_hwc/answers/hwc224.py +47 -0
- bai_python_hwc/answers/hwc225.py +50 -0
- bai_python_hwc/answers/hwc226.py +41 -0
- bai_python_hwc/answers/hwc227.py +40 -0
- bai_python_hwc/answers/hwc228.py +41 -0
- bai_python_hwc/answers/hwc229.py +51 -0
- bai_python_hwc/answers/hwc230.py +41 -0
- bai_python_hwc/answers/hwc231.py +39 -0
- bai_python_hwc/answers/hwc232.py +44 -0
- bai_python_hwc/answers/hwc233.py +49 -0
- bai_python_hwc/answers/hwc234.py +52 -0
- bai_python_hwc/answers/hwc235.py +45 -0
- bai_python_hwc/answers/hwc236.py +53 -0
- bai_python_hwc/answers/hwc237.py +56 -0
- bai_python_hwc/answers/hwc238.py +52 -0
- bai_python_hwc/answers/hwc239.py +60 -0
- bai_python_hwc/answers/hwc240.py +45 -0
- bai_python_hwc/answers/hwc241.py +48 -0
- bai_python_hwc/answers/hwc242.py +50 -0
- bai_python_hwc/answers/hwc243.py +61 -0
- bai_python_hwc/answers/hwc244.py +61 -0
- bai_python_hwc/answers/hwc245.py +47 -0
- bai_python_hwc/answers/hwc246.py +52 -0
- bai_python_hwc/answers/hwc247.py +76 -0
- bai_python_hwc/answers/hwc301.py +44 -0
- bai_python_hwc/answers/hwc302.py +53 -0
- bai_python_hwc/answers/hwc303.py +63 -0
- bai_python_hwc/answers/hwc304.py +56 -0
- bai_python_hwc/answers/hwc305.py +59 -0
- bai_python_hwc/answers/hwc306.py +60 -0
- bai_python_hwc/answers/hwc307.py +50 -0
- bai_python_hwc/answers/hwc308.py +59 -0
- bai_python_hwc/answers/hwc309.py +48 -0
- bai_python_hwc/answers/hwc310.py +38 -0
- bai_python_hwc/answers/hwc311.py +48 -0
- bai_python_hwc/answers/hwc312.py +49 -0
- bai_python_hwc/answers/hwc313.py +54 -0
- bai_python_hwc/answers/hwc314.py +49 -0
- bai_python_hwc/answers/hwc315.py +63 -0
- bai_python_hwc/answers/hwc316.py +65 -0
- bai_python_hwc/answers/hwc317.py +57 -0
- bai_python_hwc/answers/hwc318.py +55 -0
- bai_python_hwc/answers/hwc319.py +50 -0
- bai_python_hwc/answers/hwc320.py +84 -0
- bai_python_hwc/answers/hwc321.py +49 -0
- bai_python_hwc/answers/hwc322.py +49 -0
- bai_python_hwc/answers/hwc323.py +69 -0
- bai_python_hwc/answers/hwc324.py +66 -0
- bai_python_hwc/answers/hwc325.py +49 -0
- bai_python_hwc/answers/hwc326.py +53 -0
- bai_python_hwc/answers/hwc327.py +38 -0
- bai_python_hwc/answers/hwc328.py +50 -0
- bai_python_hwc/answers/hwc329.py +59 -0
- bai_python_hwc/answers/hwc330.py +45 -0
- bai_python_hwc/answers/hwc332.py +57 -0
- bai_python_hwc/answers/hwc401.py +50 -0
- bai_python_hwc/answers/hwc402.py +43 -0
- bai_python_hwc/answers/hwc403.py +73 -0
- bai_python_hwc/answers/hwc404.py +51 -0
- bai_python_hwc/answers/hwc405.py +62 -0
- bai_python_hwc/answers/hwc406.py +66 -0
- bai_python_hwc/answers/hwc407.py +49 -0
- bai_python_hwc/answers/hwc408.py +67 -0
- bai_python_hwc/answers/hwc409.py +51 -0
- bai_python_hwc/answers/hwc410.py +52 -0
- bai_python_hwc/answers/hwc411.py +57 -0
- bai_python_hwc/answers/hwc412.py +53 -0
- bai_python_hwc/answers/hwc413.py +65 -0
- bai_python_hwc/answers/hwc414.py +50 -0
- bai_python_hwc/answers/hwc415.py +61 -0
- bai_python_hwc/answers/hwc416.py +69 -0
- bai_python_hwc/answers/hwc418.py +47 -0
- bai_python_hwc/answers/hwc419.py +62 -0
- bai_python_hwc/answers/hwc421.py +51 -0
- bai_python_hwc/answers/hwc424.py +48 -0
- bai_python_hwc/answers/hwc501.py +63 -0
- bai_python_hwc/answers/hwc502.py +69 -0
- bai_python_hwc/answers/hwc503.py +75 -0
- bai_python_hwc/answers/hwc504.py +52 -0
- bai_python_hwc/answers/hwc505.py +63 -0
- bai_python_hwc/answers/hwc506.py +61 -0
- bai_python_hwc/answers/hwc508.py +60 -0
- bai_python_hwc/answers/hwc509.py +85 -0
- bai_python_hwc/answers/hwc510.py +56 -0
- bai_python_hwc/answers/hwc511.py +52 -0
- bai_python_hwc/answers/hwc513.py +63 -0
- bai_python_hwc/answers/hwc514.py +74 -0
- bai_python_hwc/answers/hwc515.py +83 -0
- bai_python_hwc/answers/hwc516.py +67 -0
- bai_python_hwc/answers/hwc517.py +46 -0
- bai_python_hwc/answers/hwc520.py +54 -0
- bai_python_hwc/answers/hwc526.py +58 -0
- bai_python_hwc/attachments/hwc424.pdf +0 -0
- bai_python_hwc/attachments/hwc501.pdf +0 -0
- bai_python_hwc/questions/hwc101.txt +17 -0
- bai_python_hwc/questions/hwc103.txt +27 -0
- bai_python_hwc/questions/hwc104.txt +22 -0
- bai_python_hwc/questions/hwc105.txt +23 -0
- bai_python_hwc/questions/hwc106.txt +26 -0
- bai_python_hwc/questions/hwc107.txt +29 -0
- bai_python_hwc/questions/hwc108.txt +18 -0
- bai_python_hwc/questions/hwc109.txt +24 -0
- bai_python_hwc/questions/hwc110.txt +16 -0
- bai_python_hwc/questions/hwc111.txt +25 -0
- bai_python_hwc/questions/hwc112.txt +13 -0
- bai_python_hwc/questions/hwc113.txt +28 -0
- bai_python_hwc/questions/hwc114.txt +35 -0
- bai_python_hwc/questions/hwc115.txt +15 -0
- bai_python_hwc/questions/hwc116.txt +13 -0
- bai_python_hwc/questions/hwc117.txt +14 -0
- bai_python_hwc/questions/hwc118.txt +25 -0
- bai_python_hwc/questions/hwc119.txt +18 -0
- bai_python_hwc/questions/hwc120.txt +23 -0
- bai_python_hwc/questions/hwc121.txt +26 -0
- bai_python_hwc/questions/hwc122.txt +21 -0
- bai_python_hwc/questions/hwc123.txt +21 -0
- bai_python_hwc/questions/hwc124.txt +19 -0
- bai_python_hwc/questions/hwc125.txt +31 -0
- bai_python_hwc/questions/hwc126.txt +18 -0
- bai_python_hwc/questions/hwc127.txt +17 -0
- bai_python_hwc/questions/hwc128.txt +14 -0
- bai_python_hwc/questions/hwc130.txt +23 -0
- bai_python_hwc/questions/hwc131.txt +19 -0
- bai_python_hwc/questions/hwc132.txt +16 -0
- bai_python_hwc/questions/hwc133.txt +39 -0
- bai_python_hwc/questions/hwc134.txt +22 -0
- bai_python_hwc/questions/hwc135.txt +29 -0
- bai_python_hwc/questions/hwc136.txt +20 -0
- bai_python_hwc/questions/hwc201.txt +20 -0
- bai_python_hwc/questions/hwc202.txt +25 -0
- bai_python_hwc/questions/hwc203.txt +26 -0
- bai_python_hwc/questions/hwc204.txt +32 -0
- bai_python_hwc/questions/hwc205.txt +28 -0
- bai_python_hwc/questions/hwc206.txt +28 -0
- bai_python_hwc/questions/hwc207.txt +16 -0
- bai_python_hwc/questions/hwc208.txt +27 -0
- bai_python_hwc/questions/hwc209.txt +15 -0
- bai_python_hwc/questions/hwc210.txt +28 -0
- bai_python_hwc/questions/hwc211.txt +35 -0
- bai_python_hwc/questions/hwc212.txt +29 -0
- bai_python_hwc/questions/hwc213.txt +27 -0
- bai_python_hwc/questions/hwc214.txt +27 -0
- bai_python_hwc/questions/hwc215.txt +28 -0
- bai_python_hwc/questions/hwc216.txt +22 -0
- bai_python_hwc/questions/hwc217.txt +17 -0
- bai_python_hwc/questions/hwc218.txt +18 -0
- bai_python_hwc/questions/hwc219.txt +22 -0
- bai_python_hwc/questions/hwc220.txt +28 -0
- bai_python_hwc/questions/hwc221.txt +18 -0
- bai_python_hwc/questions/hwc222.txt +20 -0
- bai_python_hwc/questions/hwc223.txt +18 -0
- bai_python_hwc/questions/hwc224.txt +23 -0
- bai_python_hwc/questions/hwc225.txt +26 -0
- bai_python_hwc/questions/hwc226.txt +18 -0
- bai_python_hwc/questions/hwc227.txt +15 -0
- bai_python_hwc/questions/hwc228.txt +16 -0
- bai_python_hwc/questions/hwc229.txt +20 -0
- bai_python_hwc/questions/hwc230.txt +18 -0
- bai_python_hwc/questions/hwc231.txt +13 -0
- bai_python_hwc/questions/hwc232.txt +19 -0
- bai_python_hwc/questions/hwc233.txt +21 -0
- bai_python_hwc/questions/hwc234.txt +27 -0
- bai_python_hwc/questions/hwc235.txt +18 -0
- bai_python_hwc/questions/hwc236.txt +23 -0
- bai_python_hwc/questions/hwc237.txt +28 -0
- bai_python_hwc/questions/hwc238.txt +25 -0
- bai_python_hwc/questions/hwc239.txt +28 -0
- bai_python_hwc/questions/hwc240.txt +21 -0
- bai_python_hwc/questions/hwc241.txt +25 -0
- bai_python_hwc/questions/hwc242.txt +23 -0
- bai_python_hwc/questions/hwc243.txt +35 -0
- bai_python_hwc/questions/hwc244.txt +25 -0
- bai_python_hwc/questions/hwc245.txt +24 -0
- bai_python_hwc/questions/hwc246.txt +28 -0
- bai_python_hwc/questions/hwc247.txt +51 -0
- bai_python_hwc/questions/hwc301.txt +23 -0
- bai_python_hwc/questions/hwc302.txt +26 -0
- bai_python_hwc/questions/hwc303.txt +32 -0
- bai_python_hwc/questions/hwc304.txt +32 -0
- bai_python_hwc/questions/hwc305.txt +31 -0
- bai_python_hwc/questions/hwc306.txt +31 -0
- bai_python_hwc/questions/hwc307.txt +29 -0
- bai_python_hwc/questions/hwc308.txt +30 -0
- bai_python_hwc/questions/hwc309.txt +25 -0
- bai_python_hwc/questions/hwc310.txt +15 -0
- bai_python_hwc/questions/hwc311.txt +23 -0
- bai_python_hwc/questions/hwc312.txt +19 -0
- bai_python_hwc/questions/hwc313.txt +26 -0
- bai_python_hwc/questions/hwc314.txt +27 -0
- bai_python_hwc/questions/hwc315.txt +21 -0
- bai_python_hwc/questions/hwc316.txt +36 -0
- bai_python_hwc/questions/hwc317.txt +28 -0
- bai_python_hwc/questions/hwc318.txt +27 -0
- bai_python_hwc/questions/hwc319.txt +26 -0
- bai_python_hwc/questions/hwc320.txt +42 -0
- bai_python_hwc/questions/hwc321.txt +27 -0
- bai_python_hwc/questions/hwc322.txt +26 -0
- bai_python_hwc/questions/hwc323.txt +24 -0
- bai_python_hwc/questions/hwc324.txt +40 -0
- bai_python_hwc/questions/hwc325.txt +21 -0
- bai_python_hwc/questions/hwc326.txt +25 -0
- bai_python_hwc/questions/hwc327.txt +16 -0
- bai_python_hwc/questions/hwc328.txt +15 -0
- bai_python_hwc/questions/hwc329.txt +26 -0
- bai_python_hwc/questions/hwc330.txt +27 -0
- bai_python_hwc/questions/hwc332.txt +26 -0
- bai_python_hwc/questions/hwc401.txt +25 -0
- bai_python_hwc/questions/hwc402.txt +24 -0
- bai_python_hwc/questions/hwc403.txt +37 -0
- bai_python_hwc/questions/hwc404.txt +23 -0
- bai_python_hwc/questions/hwc405.txt +29 -0
- bai_python_hwc/questions/hwc406.txt +34 -0
- bai_python_hwc/questions/hwc407.txt +24 -0
- bai_python_hwc/questions/hwc408.txt +28 -0
- bai_python_hwc/questions/hwc409.txt +25 -0
- bai_python_hwc/questions/hwc410.txt +23 -0
- bai_python_hwc/questions/hwc411.txt +34 -0
- bai_python_hwc/questions/hwc412.txt +29 -0
- bai_python_hwc/questions/hwc413.txt +28 -0
- bai_python_hwc/questions/hwc414.txt +27 -0
- bai_python_hwc/questions/hwc415.txt +27 -0
- bai_python_hwc/questions/hwc416.txt +36 -0
- bai_python_hwc/questions/hwc418.txt +25 -0
- bai_python_hwc/questions/hwc419.txt +28 -0
- bai_python_hwc/questions/hwc421.txt +23 -0
- bai_python_hwc/questions/hwc424.txt +20 -0
- bai_python_hwc/questions/hwc501.txt +23 -0
- bai_python_hwc/questions/hwc502.txt +41 -0
- bai_python_hwc/questions/hwc503.txt +36 -0
- bai_python_hwc/questions/hwc504.txt +18 -0
- bai_python_hwc/questions/hwc505.txt +25 -0
- bai_python_hwc/questions/hwc506.txt +32 -0
- bai_python_hwc/questions/hwc508.txt +24 -0
- bai_python_hwc/questions/hwc509.txt +42 -0
- bai_python_hwc/questions/hwc510.txt +25 -0
- bai_python_hwc/questions/hwc511.txt +23 -0
- bai_python_hwc/questions/hwc513.txt +25 -0
- bai_python_hwc/questions/hwc514.txt +35 -0
- bai_python_hwc/questions/hwc515.txt +46 -0
- bai_python_hwc/questions/hwc516.txt +26 -0
- bai_python_hwc/questions/hwc517.txt +20 -0
- bai_python_hwc/questions/hwc520.txt +27 -0
- bai_python_hwc/questions/hwc526.txt +36 -0
- bai_python_hwc-1.0.0.dist-info/METADATA +41 -0
- bai_python_hwc-1.0.0.dist-info/RECORD +305 -0
- bai_python_hwc-1.0.0.dist-info/WHEEL +5 -0
- bai_python_hwc-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目
|
|
13
|
+
给定一个整数,编写一个函数来判断它是否是 2 的幂次方。
|
|
14
|
+
(2 的幂次方指 1, 2, 4, 8, 16, 32 ... 这类数,即 2 的 0 次方、1 次方、2 次方……)
|
|
15
|
+
注意:0 和负数都不是 2 的幂次方,应返回 False。
|
|
16
|
+
|
|
17
|
+
示例1:
|
|
18
|
+
输入: 1
|
|
19
|
+
输出: True
|
|
20
|
+
解释: 2^0= 1
|
|
21
|
+
|
|
22
|
+
示例 2:
|
|
23
|
+
输入: 16
|
|
24
|
+
输出: True
|
|
25
|
+
解释: 2^4= 16
|
|
26
|
+
|
|
27
|
+
示例 3:
|
|
28
|
+
输入: 218
|
|
29
|
+
输出: False
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目
|
|
13
|
+
给定一个非负整数 num,反复将各个位上的数字相加,直到结果为一位数。
|
|
14
|
+
|
|
15
|
+
示例:
|
|
16
|
+
输入: 38
|
|
17
|
+
输出: 2
|
|
18
|
+
解释: 各位相加的过程为:3 + 8 = 11, 1 + 1 = 2。 由于 2 是一位数,所以返回 2。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指出现次数 超过一半(大于 ⌊n/2⌋,即 n 除以 2 向下取整)的元素。
|
|
14
|
+
你可以假设数组是非空的,并且给定的数组总是存在多数元素。
|
|
15
|
+
|
|
16
|
+
示例 1:
|
|
17
|
+
|
|
18
|
+
输入: [3,2,3]
|
|
19
|
+
输出: 3
|
|
20
|
+
|
|
21
|
+
示例 2:
|
|
22
|
+
|
|
23
|
+
输入: [2,2,1,1,1,2,2]
|
|
24
|
+
输出: 2
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
实现一个函数计算 x 的整数 n 次幂,请不要直接用 ** 的方式(用循环自己实现)。
|
|
14
|
+
考虑 n 为 负数、 正数、 0 等不同情况(提示:n 为负数时,结果是 1 除以 x 的 |n| 次幂)。
|
|
15
|
+
如 x 为 3,n 为 2 时,result 返回值为:9。
|
|
16
|
+
注:本题为进阶版;基础版(只考虑 n ≥ 0、实现方式不限)见 hwc120。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给你一个按从小到大排好序的整数数组 nums(相邻元素允许相等,即"非递减"),
|
|
14
|
+
返回每个数字的平方组成的新数组,要求也按从小到大排好。
|
|
15
|
+
|
|
16
|
+
示例 1:
|
|
17
|
+
|
|
18
|
+
输入: nums = [-4,-1,0,3,10]
|
|
19
|
+
输出: [0,1,9,16,100]
|
|
20
|
+
解释: 平方后,数组变为 [16,1,0,9,100] 排序后,数组变为 [0,1,9,16,100]
|
|
21
|
+
|
|
22
|
+
示例 2:
|
|
23
|
+
|
|
24
|
+
输入: nums = [-7,-3,2,3,11]
|
|
25
|
+
输出: [4,9,9,49,121]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
写一个程序,输出从 1 到 n 数字的字符串表示。
|
|
14
|
+
|
|
15
|
+
规则:
|
|
16
|
+
1.如果 n 是3的倍数,输出“Fizz”;
|
|
17
|
+
2.如果 n 是5的倍数,输出“Buzz”;
|
|
18
|
+
3.如果 n 同时是3和5的倍数,输出 “FizzBuzz”。
|
|
19
|
+
|
|
20
|
+
示例 1:
|
|
21
|
+
|
|
22
|
+
输入: n = 15
|
|
23
|
+
输出: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
|
|
24
|
+
|
|
25
|
+
示例 2:
|
|
26
|
+
|
|
27
|
+
输入: n = 5
|
|
28
|
+
输出: ['1', '2', 'Fizz', '4', 'Buzz']
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给定一个整数,写一个函数来判断它是否是 3 的幂次方。如果是,返回 True ;否则,返回 False 。
|
|
14
|
+
整数 n 是 3 的幂次方需满足:存在整数 x 使得 n == 3**x(即 1, 3, 9, 27, 81 ... 这类数)
|
|
15
|
+
注意:0 和负数都不是 3 的幂次方,应返回 False。
|
|
16
|
+
|
|
17
|
+
示例 1:
|
|
18
|
+
|
|
19
|
+
输入: n = 27
|
|
20
|
+
输出: True
|
|
21
|
+
|
|
22
|
+
示例 2:
|
|
23
|
+
|
|
24
|
+
输入: n = 0
|
|
25
|
+
输出: False
|
|
26
|
+
|
|
27
|
+
示例 3:
|
|
28
|
+
|
|
29
|
+
输入: n = 9
|
|
30
|
+
输出: True
|
|
31
|
+
|
|
32
|
+
示例 4:
|
|
33
|
+
|
|
34
|
+
输入: n = 1
|
|
35
|
+
输出: True
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
判断101-200(包含101和200)之间有哪些素数,按照从小到大保存至 lst_rlt,最后返回该列表。
|
|
14
|
+
提示:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,则表明此数不是素数,反之是素数。 (此方法并不惟一)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
计算并返回x的平方根整数部分,其中x是非负整数。
|
|
14
|
+
由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。
|
|
15
|
+
|
|
16
|
+
示例 1:
|
|
17
|
+
输入: 4
|
|
18
|
+
输出: 2
|
|
19
|
+
|
|
20
|
+
示例 2:
|
|
21
|
+
输入: 8
|
|
22
|
+
输出: 2
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
说明: 8 的平方根是 2.82842..., 由于返回类型是整数,小数部分将被舍去。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:实现 str_rlt print(str_rlt)后如下图案(菱形):
|
|
13
|
+
*
|
|
14
|
+
***
|
|
15
|
+
*****
|
|
16
|
+
***
|
|
17
|
+
*
|
|
18
|
+
程序分析:先把图形分成两部分来看待,前三行一个规律,后两行一个规律,利用双重 for 循环,第一层控制行,第二层控制列。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:计算幂次方
|
|
13
|
+
|
|
14
|
+
编写一个 Python 程序,计算并输出给定底数 x 和指数 n 的幂次方结果。
|
|
15
|
+
|
|
16
|
+
幂次方的定义如下:
|
|
17
|
+
|
|
18
|
+
x 的 0 次幂是 1。
|
|
19
|
+
x 的正整数 n 次幂是 x 乘以自己 n 次,即 x^n = x * x * ... * x (n 次)。
|
|
20
|
+
例如,2 的 3 次幂是 2^3 = 2 * 2 * 2 = 8。
|
|
21
|
+
|
|
22
|
+
请编写一个函数 TEST_DO_NOT_CHANGE(x, n),其中 x 为底数,n 为指数,返回 x^n 的结果。
|
|
23
|
+
注:本题为 基础版(只考虑 n ≥ 0,实现方式不限);进阶版(不能用 **,且要处理负指数)见 hwc110。
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给你一个由 n 个元素组成的整数数组 nums 和一个整数 k 。
|
|
14
|
+
请你找出平均数最大的、长度为 k 的连续一段(连续子数组),并输出这个最大平均数。
|
|
15
|
+
任何误差小于 10^-5(即 0.00001)的答案都将被视为正确答案。
|
|
16
|
+
|
|
17
|
+
示例 1:
|
|
18
|
+
|
|
19
|
+
输入: nums = [1,12,-5,-6,50,3], k = 4
|
|
20
|
+
输出: 12.75
|
|
21
|
+
解释: 最大平均数 (12-5-6+50)/4 = 51/4 = 12.75
|
|
22
|
+
|
|
23
|
+
示例 2:
|
|
24
|
+
|
|
25
|
+
输入: nums = [5], k = 1
|
|
26
|
+
输出: 5.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
使用冒泡排序方法对以下列表进行排序:
|
|
14
|
+
提示:冒泡排序的步骤:
|
|
15
|
+
1、比较相邻的元素。如果第一个比第二个大,就交换他们两个。
|
|
16
|
+
2、对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。这步做完后,最后的元素会是最大的数。
|
|
17
|
+
3、针对所有的元素重复以上的步骤,除了最后一个。
|
|
18
|
+
4、持续每次对越来越少的元素重复上面的步骤,直到没有任何一对数字需要比较。
|
|
19
|
+
尝试将以下列表用冒泡法进行排序,结果直接输出排序后的列表
|
|
20
|
+
例如 arr3 = [67,23,8,54,31,49]
|
|
21
|
+
排序后输出的result形式为: [8, 23, 31, 49, 54, 67]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目
|
|
13
|
+
给定一个二进制数组, 计算其中最大连续 1 的个数。
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
示例:
|
|
18
|
+
|
|
19
|
+
输入:[1,1,0,1,1,1]
|
|
20
|
+
输出:3
|
|
21
|
+
解释:开头的两位和最后的三位都是连续 1 ,所以最大连续 1 的个数是 3.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:(改编自计算机二级 Python 真题·综合应用题·枚举考点)
|
|
13
|
+
水仙花数是指一个 3 位正整数,其各位数字的立方和等于它本身。
|
|
14
|
+
例如:153 = 1^3 + 5^3 + 3^3,370 = 3^3 + 7^3 + 0^3。
|
|
15
|
+
请找出 100 ~ 999(含)之间所有的水仙花数,并按从小到大的顺序存入列表返回。
|
|
16
|
+
|
|
17
|
+
示例:
|
|
18
|
+
输入:无参数
|
|
19
|
+
输出:[153, 370, 371, 407]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:最高海拔
|
|
13
|
+
有一个自行车手打算进行一场公路骑行,这条路线总共由 n + 1 个不同海拔的点组成。自行车手从海拔为 0 的点 0 开始骑行。
|
|
14
|
+
给你一个长度为 n 的整数数组 gain ,其中 gain[i] 表示从第 i 个点骑到第 i+1 个点时海拔变化了多少(正数表示上坡升高,负数表示下坡降低)。请你返回整条路线中 最高点的海拔 。
|
|
15
|
+
|
|
16
|
+
提示:
|
|
17
|
+
n == gain.length
|
|
18
|
+
1 <= n <= 100
|
|
19
|
+
-100 <= gain[i] <= 100
|
|
20
|
+
|
|
21
|
+
示例 1:
|
|
22
|
+
|
|
23
|
+
输入:gain = [-5,1,5,0,-7]
|
|
24
|
+
输出:1
|
|
25
|
+
解释:海拔高度依次为 [0,-5,-4,1,1,-6] 。最高海拔为 1 。
|
|
26
|
+
|
|
27
|
+
示例 2:
|
|
28
|
+
|
|
29
|
+
输入:gain = [-4,-3,-2,-1,4,3,2]
|
|
30
|
+
输出:0
|
|
31
|
+
解释:海拔高度依次为 [0,-4,-7,-9,-10,-6,-3,-1] 。最高海拔为 0 。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
将整数列表中所有的偶数摘选出来并输出一个新的列表。
|
|
14
|
+
例如:nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]输出结果为[2, 4, 6, 8, 10]
|
|
15
|
+
请将以下列表中的偶数筛选出来:
|
|
16
|
+
num1 = [11,16,26,7,31]
|
|
17
|
+
num2 = [13,18,21,37,42]
|
|
18
|
+
num3 = [31,17,46,12,77]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
已知一个3*3矩阵A,A的元素依次为1-9的平方
|
|
14
|
+
|1^2 2^2 3^2|
|
|
15
|
+
A=|4^2 5^2 6^2|,求该矩阵主对角线元素之和(主对角线即从左上方到右下方的那条斜线,行号和列号相同的元素:1^2、5^2、9^2)。
|
|
16
|
+
|7^2 8^2 9^2|
|
|
17
|
+
程序分析:利用双重for循环控制输入二维数组,再将a[i][i]累加后输出。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给定两个字符串 s1 和 s2,请编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串。
|
|
14
|
+
|
|
15
|
+
示例 1:
|
|
16
|
+
|
|
17
|
+
输入: s1 = "abc", s2 = "bca"
|
|
18
|
+
输出: True
|
|
19
|
+
示例 2:
|
|
20
|
+
|
|
21
|
+
输入: s1 = "abc", s2 = "bad"
|
|
22
|
+
输出: False
|
|
23
|
+
说明:两个字符串长度相同且仅由字符组成;字符出现次数完全相同时返回 True,否则返回 False。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
求数字 0—7 在数字不重复使用的条件下所能组成的 n 位奇数个数。
|
|
14
|
+
程序分析:
|
|
15
|
+
组成 1 位数是 4 个;后续各位不能重复使用已经选过的数字,且最高位不能为 0。
|
|
16
|
+
输入是 n n为几位数
|
|
17
|
+
输出是 奇数个数
|
|
18
|
+
如 输入 n=4
|
|
19
|
+
输出的 rlt_sum=7*8*8*4
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
查找字符串 str_2 在 str_1 中第一次出现的位置。下标从 0 开始,
|
|
14
|
+
返回 (start, end):start 是匹配段第一个字符的下标,end 是匹配段最后一个字符的下标(包含该字符);
|
|
15
|
+
如果不存在返回 (-1, -1)。
|
|
16
|
+
例如:在字符串 abcdefg 中查找 cde,匹配段是下标 2、3、4 的字符,返回 (2, 4)。
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
0, 1, 2, ..., n 这 n+1 个连续整数中,有一个数缺席了。数组 nums 里装着剩下的 n 个数(顺序打乱、互不重复),
|
|
14
|
+
请找出缺席的那个数。
|
|
15
|
+
|
|
16
|
+
进阶(可选):
|
|
17
|
+
|
|
18
|
+
你能否只把数组遍历一遍、并且几乎不使用额外空间(不新建与数组等长的容器)解决此问题?
|
|
19
|
+
|
|
20
|
+
示例 1:
|
|
21
|
+
|
|
22
|
+
输入:nums = [3,0,1]
|
|
23
|
+
输出:2
|
|
24
|
+
解释:n = 3,因为有 3 个数字,所以所有的数字都在范围 [0,3] 内。2 是丢失的数字,因为它没有出现在 nums 中。
|
|
25
|
+
示例 2:
|
|
26
|
+
|
|
27
|
+
输入:nums = [0,1]
|
|
28
|
+
输出:2
|
|
29
|
+
解释:n = 2,因为有 2 个数字,所以所有的数字都在范围 [0,2] 内。2 是丢失的数字,因为它没有出现在 nums 中。
|
|
30
|
+
示例 3:
|
|
31
|
+
|
|
32
|
+
输入:nums = [9,6,4,2,3,5,7,0,1]
|
|
33
|
+
输出:8
|
|
34
|
+
解释:n = 9,因为有 9 个数字,所以所有的数字都在范围 [0,9] 内。8 是丢失的数字,因为它没有出现在 nums 中。
|
|
35
|
+
示例 4:
|
|
36
|
+
|
|
37
|
+
输入:nums = [0]
|
|
38
|
+
输出:1
|
|
39
|
+
解释:n = 1,因为有 1 个数字,所以所有的数字都在范围 [0,1] 内。1 是丢失的数字,因为它没有出现在 nums 中。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:计算斐波那契数列
|
|
13
|
+
|
|
14
|
+
编写一个 Python 程序,计算并输出斐波那契数列的前 n 个数字。
|
|
15
|
+
|
|
16
|
+
斐波那契数列的定义如下:
|
|
17
|
+
|
|
18
|
+
第一个和第二个数字都是 1。
|
|
19
|
+
从第三个数字开始,每个数字都是前两个数字之和。
|
|
20
|
+
例如,前几个斐波那契数字是:1, 1, 2, 3, 5, 8, 13, 21, ...
|
|
21
|
+
|
|
22
|
+
要求:返回一个列表,包含斐波那契数列的前 n 项。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:
|
|
13
|
+
给定一个字符串来代表一个学生的出勤记录,这个记录仅包含以下三个字符:
|
|
14
|
+
|
|
15
|
+
'A' : Absent,缺勤
|
|
16
|
+
'L' : Late,迟到
|
|
17
|
+
'P' : Present,到场
|
|
18
|
+
如果一个学生的出勤记录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏。
|
|
19
|
+
|
|
20
|
+
你需要根据这个学生的出勤记录判断他是否会被奖赏。
|
|
21
|
+
|
|
22
|
+
示例 1:
|
|
23
|
+
|
|
24
|
+
输入: "PPALLP"
|
|
25
|
+
输出: True
|
|
26
|
+
示例 2:
|
|
27
|
+
|
|
28
|
+
输入: "PPALLL"
|
|
29
|
+
输出: False
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
请只在 "
|
|
2
|
+
##########start下面可以改动
|
|
3
|
+
|
|
4
|
+
##########end上面可以改动 "
|
|
5
|
+
|
|
6
|
+
中间部分作答,作答行数自由调整
|
|
7
|
+
|
|
8
|
+
请不要使用 input() 函数
|
|
9
|
+
|
|
10
|
+
此题在期中考试考察范围内,作业需提交,注意期中考试有卷面分,请认真作答。
|
|
11
|
+
|
|
12
|
+
题目:查找素数
|
|
13
|
+
|
|
14
|
+
编写一个 Python 程序,接受用户输入的正整数 n,然后查找并输出从 2 到 n 之间的所有素数。
|
|
15
|
+
|
|
16
|
+
素数是指只能被 1 和自身整除的正整数。例如,2、3、5、7、11 等都是素数。
|
|
17
|
+
|
|
18
|
+
编写一个函数 TEST_DO_NOT_CHANGE(n),它接受一个正整数 n 作为参数,返回一个包含从 2 到 n 之间的所有素数的列表。
|
|
19
|
+
|
|
20
|
+
例如,如果用户输入 n = 20,程序应该输出 [2, 3, 5, 7, 11, 13, 17, 19]。
|