Skip to content

Commit 6862be9

Browse files
committed
update day3 homework
1 parent b32b700 commit 6862be9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

D03/homework.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import numpy as np
2+
3+
V1 = 20000
4+
V0 = 20
5+
6+
def db2V1(db):
7+
return np.power(10,db/20)*V0
8+
9+
gdb = 20*np.log10(V1/V0)
10+
print('正常的談話的聲壓為 20000 微巴斯卡,請問多少分貝: answer is %d db' % gdb)
11+
12+
V30db = db2V1(30)
13+
V50db = db2V1(50)
14+
15+
print('30db\'s V1 is %d' % V30db)
16+
print('50db\'s V1 is %d' % V50db)
17+
18+
print('30 分貝的聲壓會是 50 分貝的幾倍 = {:.3f}'.format(V30db/V50db) )
19+

0 commit comments

Comments
 (0)