# Akuli-python-tutorial-learning **Repository Path**: shanghai_sansi_co_ltd/Akuli-python-tutorial-learning ## Basic Information - **Project Name**: Akuli-python-tutorial-learning - **Description**: 入门学习 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2020-05-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Akuli-python-tutorial-learning # 1 介绍 python入门学习 # 2 python的常规输出 1.单纯输入字符串的报错 ```python >>> hello --------------------------------------------------------------------------- NameError Traceback (most recent call last) in ----> 1 hello NameError: name 'hello' is not defined ``` 2.输入数字,输出数字 ```python >>>123 123 ``` 3.输入组合的数字,没有报错,输出了数字集合。 ```python >>>3,4 (3, 4) ``` 4.带双引号输入字符“hello world”,输出带单引号字符。 ```python >>>"hello world" 'hello world' ``` 5.也可以输出带单引号的字符,带双引号输出 ```python >>>"Today's sunny" "Today's sunny" ``` 6.可以输出算数,注意^在python中做XOR运算 ```python >>>1+2 8 >>>3*4 12 >>>5/6 0.8333333333333334 >>>5-6 -1 >>>5**2 25 >>>2^7 5 ``` # 3 变量、布尔值、空 1.变量 变量用于传递数值或字符串,一个变量可以被多次赋值,重复赋值,但是只能赋予一个值。 变量区分大小写。 程序语言中的关键字不能被创建为变量,如if,also,for…… 变量名称有讲究,有意义便于他人读懂程序为优。 ```python >>>a=1 >>>a 1 >>>if=1 if File "", line 1 if=1 ^ SyntaxError: invalid syntax >>>a="hello";b=2 >>>a,b ('hello', 2) >>>Think=1;tTink=2;thInk=3 >>>Think,tTink,thInk (1, 2, 3) ``` 2.布尔值 布尔值有两个,true和false。通过“==”比较获得。 实际上输入“a==1”与“(a==1) == True”同意。 ```python >>>a=1 >>>a == 1 True >>>a==2 False ``` 3.None 空值,无,None,也有其用场。 ```python >>>thingy = None >>>thingy >>>print (thingy) None ``` 4.其他比较 | Usage | Description | True examples | |-----------|-----------------------------------|-----------------------| | `a == b` | a is equal to b | `1 == 1` | | `a != b` | a is not equal to b | `1 != 2` | | `a > b` | a is greater than b | `2 > 1` | | `a >= b` | a is greater than or equal to b | `2 >= 1`, `1 >= 1` | | `a < b` | a is less than b | `1 < 2` | | `a <= b` | a is less than or equal to b | `1 <= 2`, `1 <= 1` | 与、或 | Usage | Description | True example | |-----------|-------------------------------------------|-----------------------------------| | `a and b` | a is True and b is True | `1 == 1 and 2 == 2` | | `a or b` | a is True, b is True or they're both True | `False or 1 == 1`, `True or True` | ```python >>>1==1 and 2==2 True >>>1 > 1 and 2==2 False ```