Skip to content

Commit 7281621

Browse files
committed
update homework 3 and 4
1 parent 6862be9 commit 7281621

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

D03/homework.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ def db2V1(db):
1515
print('30db\'s V1 is %d' % V30db)
1616
print('50db\'s V1 is %d' % V50db)
1717

18-
print('30 分貝的聲壓會是 50 分貝的幾倍 = {:.3f}'.format(V30db/V50db) )
18+
print('30 分貝的聲壓會是 50 分貝的幾倍 = %s' % (V30db/V50db) )
1919

D04/homework.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import numpy as np
2+
3+
english_score = np.array([55,89,76,65,48,70])
4+
math_score = np.array([60,85,60,68,55,60])
5+
chinese_score = np.array([45,90,82,72,66,77])
6+
7+
#1.有多少學生英文成績比數學成績高?
8+
ans1 = np.greater(english_score,math_score)
9+
# print(ans1)
10+
Ans = [ A for A in ans1 if A==True ]
11+
print('有 %d 個學生英文成績比數學成績高' % len(Ans))
12+
13+
#2.是否全班同學最高分都是國文?
14+
ans2 = np.greater(chinese_score,english_score,math_score )
15+
# print(ans2)
16+
Ans = [ A for A in ans2 if A==1 ]
17+
print('是否全班同學最高分都是國文: %s' % ( len(Ans)==6) )
18+

0 commit comments

Comments
 (0)