代码提示用户输入两次数字,然后显示结果(python)

时间:2014-03-29 18:32:00

标签: python-3.x

CODE

def main():

    numbers()

    add()

    display()


def numbers():

    num1 = int(input("Enter a number: "))

    num2 = int(input("Enter another number: "))

    return num1,num2


def add():

    num1,num2 = numbers()

    print(num1,"and",num2,"=",num1 + num2)


def display():

    num1,num2 = numbers()

    print("The numbers that you chose are",num1,"and",num2)

    print("Both numbers added equal :", num1+num2)

main()

输出

Enter a number: 22

Enter another number: 22

Enter a number: 22

Enter another number: 22

22 and 22 = 44

Enter a number: 22

Enter another number: 22

The numbers that you chose are 22 and 22

Both numbers added equal : 44

0 个答案:

没有答案