Educoder Python入門之模塊

題目鏈接:https://www.educoder.net/tasks/qeapuclwiyjv

第1關:模塊的定義

#coding=utf-8

import math
from decimal import Decimal
# 輸入正整數a和b
a = float(input())
b = float(input())

# 請在此添加代碼,輸入直角三角形的兩個直角邊的邊長a和b,計算出其斜邊邊長
#********** Begin *********#
target = Decimal(math.sqrt(a**2+b**2)).quantize(Decimal("0.000"))
print(target)

#********** End **********#

第2關:內置模塊中的內置函數

#coding=utf-8

# 導入math模塊
import math

# 輸入兩個整數a和b
a = int(input())
b = int(input())

# 請在此添加代碼,要求判斷是否存在兩個整數,它們的和爲a,積爲b
#********** Begin *********#
count=0
for x in range(a):
    for y in range(a):
        if x + y == a and x * y == b:
            count+=1
if count == 0:
    print('No')
else:
    print('Yes')



#********** End **********#

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章