You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
424 B
19 lines
424 B
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Wed May 5 16:11:11 2021
|
|
# a4-1 计算两个正整数间所有整数的和
|
|
@author: Admin
|
|
"""
|
|
#定义函数addab(a,b)
|
|
def addab(a,b):
|
|
s=0
|
|
for i in range(a,b+1):
|
|
s=s+i
|
|
return s
|
|
|
|
x = int(input("请输入第一个数:"))
|
|
y = int(input("请输入第二个数:"))
|
|
#调用函数
|
|
result = addab(x,y)
|
|
|
|
print('{}+...+{}={}'.format(x,y,result)) |