-
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
ff038ec
commit d0e14f4
Showing
4 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
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,45 @@ | ||
# 四則運算 | ||
|
||
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="") | ||
|
||
|
||
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,33 @@ | ||
# 使用者輸入一個正整數,算整數平方根 | ||
|
||
while True: | ||
|
||
print("\n我要來算平方根, you know.") | ||
n=int(input("請輸入一個正整數 : ")) | ||
x=1 | ||
|
||
while x**2 <= n: | ||
|
||
if x**2 == n: | ||
print("\n",n,"的平方根 = " ,x) | ||
break | ||
|
||
else : | ||
x+=1 | ||
if x**2>n : | ||
print("\nSorry 我只有國中智商...") | ||
print("輸入個我會算的 QAQ\n") | ||
continue | ||
|
||
else: | ||
w=input("\n還要再看我表演一次嗎? y or n :") | ||
|
||
if w=="y" : | ||
|
||
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,42 @@ | ||
# 輸出九九乘法表 | ||
|
||
print("Ladies & Gentleman !") | ||
print("來看我一次變出九九乘法表囉!") | ||
print("倒數五秒~\n") | ||
|
||
import threading | ||
import time | ||
|
||
def fun_timer(): | ||
|
||
print("秒") | ||
global timer | ||
timer = threading.Timer(1, fun_timer) | ||
timer.start() | ||
|
||
print("秒") | ||
|
||
timer = threading.Timer(1, fun_timer) | ||
timer.start() | ||
|
||
time.sleep(5) | ||
timer.cancel() | ||
|
||
|
||
for w in range(1,10) : | ||
|
||
for n in range(1,9): | ||
|
||
if n*w <10 : | ||
print(n,"x",w,"= ",n*w,end=" ") | ||
|
||
else: | ||
print(n,"x",w,"=",n*w,end=" ") | ||
|
||
if w==1: | ||
print(9,"x",w,"= ",9*w) | ||
else: | ||
print(9,"x",w,"=",9*w) | ||
|
||
|
||
|
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,23 @@ | ||
# 質數偵測 | ||
|
||
print("\n我要來幫你檢查是不是質數了, you know.") | ||
n=int(input("請輸入一個正整數 : ")) | ||
print("\n",n,"的因數有 : ",end="") | ||
const=0 | ||
|
||
for x in range(1,n+1) : | ||
|
||
if n%x ==0 : | ||
|
||
print(x,",",end=" ") | ||
const+=1 | ||
|
||
|
||
if const >=3 : | ||
|
||
print("\n\n除了 1 和",n,"以外還有其他因數") | ||
print("\n所以",n,"不是質數 ~") | ||
|
||
else: | ||
print("\n\n唉呦, 看來",n,"是質數喔 ~") | ||
|