首页 > 编程语言 >【笨方法学python】ex3 - 运算符

【笨方法学python】ex3 - 运算符

时间:2022-10-05 03:56:45浏览次数:53  
标签:What greater python equal 运算符 ex3 print than

代码如下:

点击查看代码
# -*-coding: utf-8- -*-
print "中文示例"
# + plus 加号
# - minus 减号
# / slash ÷
# * asterisk ×
# % percent 余数
# < less-than 小于
# > greater-than 大于
# <= less-than-equal 小于等于
# >= greater-than-equal 大于等于

print "I will now count my chickens:"

print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4

print "Now I will count the eggs:"

print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 # 1 + 0 + 0 + 6

print "Is it true that 3 + 2 < 5 - 7 ?"
print 3 + 2 < 5 - 7

print "What is 3 + 2 ?", 3 + 2
print "What is 5 - 7 ?", 5 - 7

print "Oh, that's why it's False."

print "How about some more."

print "Is it greater ?", 5 > -2 # greater 更大的
print "Is it greater or equal ?", 5 >= -2 # 大于等于
print "Is it less or equal ?", 5 <= -2 # 小于等于

print 8.0 / 3
print 8.0 // 3
# “/”是浮点除法 , “//”是整除法

执行结果:
image

标签:What,greater,python,equal,运算符,ex3,print,than
From: https://www.cnblogs.com/TiramisuPS/p/16754959.html

相关文章

  • 【笨方法学python】ex4 - 变量和命名
    代码如下:点击查看代码#-*-coding:utf-8--*-#变量和命名cars=100#100辆车space_in_a_car=4#每辆车四个位置drivers=30#30个司机passengers=90#......
  • 【笨方法学python】ex5 - 更多的变量和打印
    代码如下:点击查看代码#-*-coding:utf-8--*-#更多的变量和打印my_name='P.S'my_age=28my_height=183#cmmy_weight=100#kgmy_eyes='Black'my_te......
  • 【笨方法学python】ex6 - 字符串(string)和文本
    代码如下:点击查看代码#-*-coding:utf-8--*-#字符串(string)和文本x="Thereare%dtypesofpeople."%10binary="bianry"do_not="don't"y="Thosewh......
  • 【笨方法学python】ex7 - 更多打印
    代码如下:点击查看代码#-*-coding:utf-8--*-#更多打印print"Maryhadalittlelamb."print"Itsfleefewaswhiteas%s."%'snow'print"Andeverywhereth......
  • 【笨方法学python】ex8 - 打印,打印
    代码如下:点击查看代码#-*-coding:utf-8--*-#打印,打印formatter="%r%r%r%r"printformatter%(1,2,3,4)printformatter%('one','two','three','......
  • 【笨方法学python】ex9 - 打印,打印,打印
    代码如下:点击查看代码#-*-coding:utf-8--*-#打印,打印,打印#Here'ssomenewstrangestuff,remembertypeitexactly.days="MonTueWedThuFriSatSun"......
  • 【笨方法学python】ex2 - 注释符
    代码如下:点击查看代码#-*-coding:utf-8-*-#Acomment,thisissoyoucanreadyourprogramlater.#Anythingafterthe#isignoredbypython.#一个注释......
  • 【笨方法学python】print
    代码如下#-*-coding:utf-8--*-print"HelloWorld"print"HelloAgain"print"Iliketypingthis."print"Thisisfun."print"Yay!Printing."print"I'dmuch......
  • Python 注册菜单
    我们看到下面的示例图是在右键文件夹上查看菜单,带有两级的菜单选项。需要使用管理员权限运行因为右键菜单需要注册表信息,打开注册表需要管理员权限UAC,所以在执行命令过......
  • python安装及环境变量配置
    python环境变量配置1、双击安装包,出现如下的安装界面,选择自定义安装2、选项设置,默认全部勾选即可3、高级配置选线,如图勾选即可4、如下图所示,安装过程中5、......