今天来看一下递归,基本内容适合初学者哦!
1.地板除法和求余
1. 地板除运算符 (floor division operator) 为 // 即先做除法,然后将结果向下保留到整数。
2. 另一个方法就是使用求余运算符 (modulus operator),% ,它会将两个数相除,返回余数。
2.布尔表达式 (boolean expression)
使用 ***== 运算符***。它比较两个运算数,
如果它们相等,则结果为 True ,否则结果为 False 。
>>>5==5
>True
>>> 5==6
>Flase
>#True 和 False 是属于 bool 类型的特殊值;它们不是字符串。
>>> type ( True )
<class 'bool '>
>>> type ( False )
<class 'bool '>
其他关系运算符有
x != y # x is not equal to y
x > y # x is greater than y
x < y # x is less than y
x >= y # x is greater than or equal to y
x <= y # x is less than or equal to y
3.逻辑运算符
三个逻辑运算符(local operators):and or not
>>> #逻辑运算符的运算数应该是布尔表达式
>>> 42 is 45
False
>>