Touge educoder-Python programming-the fourth stage functions and modules-modules

  Level 1: Module Definition

# coding=utf-8

import math

# 输入正整数a和b
a = float(input())
b = float(input())

# 请在此添加代码,输入直角三角形的两个直角边的边长a和b,计算出其斜边边长
########## Begin ##########
j=math.sqrt(a**2+b**2)
print("%.3f"%j)




########## End ##########


Level 2: Built-in functions in built-in modules

# coding=utf-8

# 导入math模块
import math

# 输入两个整数a和b
a = int(input())
b = int(input())

# 请在此添加代码,要求判断是否存在两个整数,它们的和为a,积为b
########## Begin ##########
y=0;
for i in range(a):
    if(i*(a-i)==b):
        print("Yes")
        y=1;
        break
if(y==0):
    print("No")




########## End ##########


Guess you like

Origin blog.csdn.net/long_0901/article/details/121720997