4.Python基础 运算
2015-07-30 18:33
701 查看
根据Vamei前辈的博客练习Python的,Vamei前辈博客地址:
/article/4673207.html
Python也和其它语言有加、减、乘、除、大于、小于、大于等于、小于等于、不等于、与、或、非等运算符,请看下面:
/article/4673207.html
Python也和其它语言有加、减、乘、除、大于、小于、大于等于、小于等于、不等于、与、或、非等运算符,请看下面:
>>> print (2.3+2.1) #加法 4.4 >>> print (2.5+2.6) #加法 5.1 >>> print (1.9+2.3) #加法 4.199999999999999 >>> print (2.1-0.3) #减法 1.8 >>> print (2.3*3.1) #乘法 7.13 >>> print (4.5/1.5) #除法 3.0 >>> print (3**2) #乘方 9 >>> print (9%2) #取余 1 >>> print (9%3.3) #取余 2.4000000000000004 >>> >>> >>> print (5==6) #等于 False >>> print (5==5) True >>> print (5!=6) #不等于 True >>> print (3<3, 3<=3) #小于,小于等于 False True >>> print (4>5) #大于 False >>> print (4>0) #大于 True >>> print (5 in[1, 2, 5]) #5在list里 True >>> print (3 is int) False >>> print (3 is 3) #is True >>> print (3 is 2) False >>> print (3 is not 3) #is not False >>> print (True and True, True and False) #与,and True False >>> print (False or False, True or False) #或,or False True >>> print (not True) #非,not False >>> print ((5!=3) and (1==1)) True >>> print (not -1) False >>> print (not False) True >>> print (not 0) True >>> print (not 1) False >>> print (-1==True) False >>> print (-1==False) False >>> not -1 False >>> print ("hello" == 'hello') True >>> print ("hello" != "hello") False >>> print (not "dd") False >>>
相关文章推荐
- Python进阶之闭包
- Python中lxml模块的安装
- Python 批量下载图片示例
- mac 安装pillow模块
- Python进阶之返回函数
- python 高阶函数之自定义排序
- Python xml属性/节点/文本的增删改[xml.etree.ElementTree]
- Python文件操作注意事项
- python简单分割文件的方法
- python error python version 2.7 required,which was not found in the registry
- 用python实现链表操作
- Python读取网页内容的方法
- Python UnicodeEncodeError: 'gbk' codec can't encode character u'\ufeff' in position 0:
- python特殊注释
- python查看FTP是否能连接成功的方法
- windows 64位机器安装python机器学习环境scikit_learn
- selenium for python 所有方法
- python命名规则
- 【python】Word Jumble
- Fedora22环境下Python3.4+Django1.8+MySQL5.6环境搭建