-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a5e9bf
commit 5b4cb8e
Showing
8 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
|
||
|
||
def Cal(n1,n2,op) : | ||
|
||
|
||
if op =="+": | ||
print(n1+n2) | ||
|
||
|
||
elif op =="-": | ||
print(n1-n2) | ||
|
||
|
||
elif op =="*": | ||
print(n1*n2) | ||
|
||
|
||
elif op =="/": | ||
print(n1/n2) | ||
|
||
|
||
else : | ||
print("What the hell ?") | ||
|
||
print("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
def list(n1,n2) : | ||
|
||
for w in range(n1,n2+1) : | ||
|
||
for n in range(n1,n2): | ||
|
||
if n*w <10 : | ||
print(n,"x",w,"= ",n*w,end=" ") | ||
|
||
else: | ||
print(n,"x",w,"=",n*w,end=" ") | ||
|
||
if w==1 and n2==9 : | ||
|
||
print(9,"x",w,"= ",9*w) | ||
else: | ||
|
||
print(n2,"x",w,"= ",n2*w) | ||
|
||
return | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 程式包裝 | ||
# 1. 把 99 乘法表包裝成函式,可做 n1xn2 乘法 | ||
# 2. 把四則運算機包裝成函式 | ||
# 3. 將以上函式包裝在自己的模組和封包中,並且在主程式成功使用 | ||
|
||
import Prac3.multiple as m | ||
import Prac3.calculate as c | ||
|
||
while True: | ||
|
||
print("\n1. 四則運算機\n2. n1 x n2 乘法表 \n") | ||
choice=input("輸入 1 或 2 選擇你要執行的項目 : ") | ||
|
||
if choice=="1" : | ||
|
||
while True : | ||
|
||
print('\n這是小學生計算機, 運算式請輸入 "+,-,*,/" \n') | ||
print("輸入格式 : 3 * 5 (全部輸入完請按 Enter ) \n") | ||
try: | ||
n1,op,n2=input().split() | ||
except ValueError: | ||
print("\n忘記空格了齁! 重來 OK ?!\n") | ||
continue | ||
|
||
n1=int(n1) | ||
n2=int(n2) | ||
print("= ",end="") | ||
|
||
c.Cal(n1,n2,op) | ||
break | ||
|
||
elif choice=="2" : | ||
x=int(input("\nEnter n1 : ")) | ||
y=int(input("Enter n2 : ")) | ||
|
||
if x<y: | ||
print("\n") | ||
m.list(x,y) | ||
print("\n") | ||
elif x>y: | ||
print("\n") | ||
m.list(y,x) | ||
print("\n") | ||
else: | ||
print("\n",x,"x",y,"=",x*y,"\n") | ||
|
||
else: | ||
print("\n賣鬧 ! \n") | ||
continue | ||
|
||
ans=input("Do You Wanna Play Again ? (y/n) : ") | ||
|
||
if ans=="Y" or ans=="y" : | ||
print("\n") | ||
continue | ||
else : | ||
print("\nBye !") | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# 從官網資訊學習使用系統內建的模組 random 產生 1~100 間的亂數 | ||
|
||
|
||
import random | ||
|
||
# n = random.randint(1,100) | ||
|
||
# 呈現 1~100 10x10 亂數矩陣 | ||
|
||
x=random.sample(range(1,101),k=100) | ||
a=1 | ||
while a<=100: | ||
if a%10==0: | ||
print(x[a-1]) | ||
a+=1 | ||
else: | ||
print(x[a-1],end="\t") | ||
a+=1 | ||
|