To sum up~

After studying the article for about a week, today we will summarize what we have learned before:

 

1. The installation of python is no different from installing other software, that is, Chinese and spaces should not appear in the installation path. After installation, configure the environment variables, open the command run box with cmd, enter python, press Enter, you will enter the python compilation environment, remember to switch to the English input method~

2. The operations of addition, subtraction, multiplication and division: the corresponding symbols are +, -, *, /. The number of decimal places of the operation result is the maximum number of decimal places of the operand, that is to say, if you perform a calculation with a number with three decimal places and a number with two decimal places, the result is three decimal places.

3. The operation order of python is the same as our manual operation order, first multiplication and division and then subtraction. If you want to change the symbol, add a parenthesis. Then in division, if you want to take the remainder instead of the integer quotient, you replace the / with %.

4. The next step is how to input data. The syntax is input(), and the output is print(); if you want to add Chinese in the brackets, remember to add a pair of English double quotation marks first, and then write Chinese characters in the double quotation marks .

5. The next step is to calculate the length, maximum and minimum values ​​of the array. You first create an array and assign it, then find the length like this len(), find the maximum value like this max(); find the minimum value like this min(). The parentheses are followed by the name of the array.

6. The exponentiation of multiple powers is this format 2 ** 3 represents the power of 2, and it can also be represented as pow(2,3). The absolute value is abs(), and the number to be operated on is written in parentheses.

7. There is also an if judgment statement, if followed by a condition, if the condition is met, the following statement is executed. if a == b:print("The author is so handsome!") One thing you should pay attention to is that in programming languages, the judgment is equal to ==, and an equal sign is an assignment.

8. Import the math module. In this module, the function for calculating the square root is sqrt(), the function for rounding down is floor, and the rounding up is ceil. Several functions are implemented to do this:

import math
math.sqrt(270400)

from math import sqrt
sqrt(270400)

#向下取整
import math
math.floor(32.9)

#向上取整
import math
math.ceil(32.3)

复制代码

#向下取整
from math import floor
floor(32.9)

#向上取整
from math import ceil
ceil(32.3)

好的,今天就复习到这里,好好理解一下哦~

 

(文章图片若有侵权,请联系作者删除)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325630493&siteId=291194637
sum
Recommended