Python learning (Part 1: Exchange two numbers)

1. The python language has the characteristics of simplicity and clarity. The following exchange of two numbers is written in C language and python language respectively, as follows:

"""交换两个数"""
>>> x=3
>>> y = 5
>>> z = x
>>> x = y
>>> y = z
>>> print(x,y)
5 3

2. Write it in python language as follows:

>>> x = 3
>>> y = 5
>>> x,y = y,x
>>> print(x,y)
5 3

3. Obviously, it is simpler to use python language.

Guess you like

Origin blog.csdn.net/h1998040218/article/details/129169563