Add multiply function in test.py
This commit is contained in:
21
test.py
Normal file
21
test.py
Normal file
@@ -0,0 +1,21 @@
|
||||
def multiply(a, b):
|
||||
"""
|
||||
计算两个数字的乘积并返回结果。
|
||||
|
||||
参数:
|
||||
a (int/float): 第一个数字
|
||||
b (int/float): 第二个数字
|
||||
|
||||
返回:
|
||||
int/float: a和b的乘积
|
||||
"""
|
||||
return a * b
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 测试代码
|
||||
print("测试 multiply 函数:")
|
||||
print(f"2 * 3 = {multiply(2, 3)}")
|
||||
print(f"4.5 * 2 = {multiply(4.5, 2)}")
|
||||
print(f"-5 * 6 = {multiply(-5, 6)}")
|
||||
print(f"0 * 100 = {multiply(0, 100)}")
|
||||
Reference in New Issue
Block a user