前文:
https://blog.csdn.net/qq_45802978/article/details/121627219
https://blog.csdn.net/qq_45802978/article/details/121630670
https://blog.csdn.net/qq_45802978/article/details/121648518
布尔值:True和False
1)比较两个值时会计算表达式并且返回布尔值答案
print(10 > 9) print(10 == 9) print(10 < 9)
2)if语句中运行条件时返回True或者False的结果
a = 100 b = 30 if b > a: print("b大于a") else: print("b不大于a")
bool()函数允许评估任何值,并返回True或者False
1)评估字符串和数字
2)评估两个变量
1)
2)
出现了一个错误,忘记截图了
解决链接
(9条消息) Python isinstance() arg 2 must be a type or tuple of types_qq_34623223的博客-CSDN博客 https://blog.csdn.net/qq_34623223/article/details/103091984?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163833034016780265495454%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=163833034016780265495454&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduend~default-1-103091984.first_rank_v2_pc_rank_v29&utm_term=isinstance%28%29+arg+2+must+be+a+type+or+tuple+of+types&spm=1018.2226.3001.4187
答案:
1、True
2、False
3、False
4、True
5、True 5、False
验证:
1)加减法:
2)乘除法
a=(50-5*6)/4 print(a) a=8/5 print(a)
3)取余数(同时与除法进行比较)
'''/返回为float,//返回整数,%返回余数''' a=17/3 print(a) a=17//3 print(a) a=5*3+2 print(a)
4)幂运算(**)
'''幂运算 **''' a=4**2 b=2**3 print(a,b)
1)等于(=)
2)加等于(+=)等效于x=x+
3)减等于(-=)等效于x=x-
4)乘除求余幂等都类似