三木社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 347|回复: 0
打印 上一主题 下一主题

Ex056-比较运算实验

[复制链接]

1657

主题

1684

帖子

5684

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5684
跳转到指定楼层
楼主
发表于 2017-5-31 07:57:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
实验目的:
1.学习简单的控制语句
实验代码:
  1. # main.py -- put your code here!

  2. a = 21
  3. b = 10
  4. c = 0

  5. if (a==b):
  6.     print("1 - a equal b")
  7. else:
  8.     print("1 - a not equal b")

  9. if (a!=b):
  10.     print("2 - a not equal b")
  11. else:
  12.     print("2 - a equal b")

  13. if (a<b):
  14.     print("3 -a less than b")
  15. else:
  16.     print("3 -a greater than or equal b")

  17. if (a>b):
  18.     print("4 - a greater than b")
  19. else:
  20.     print("4 - a less than or equal b")

  21. a = 5
  22. b = 20
  23. if (a<=b):
  24.     print("5 - a less than or equal b")
  25. else:
  26.     print("5 - a greater than b")

  27. if (b>=a):
  28.     print("6 - b greater than a")
  29. else:
  30.     print("6 -b less than a")
复制代码


回复

使用道具 举报

Archiver|手机版|小黑屋|三木电子社区 ( 辽ICP备11000133号-4 )

辽公网安备 21021702000620号

GMT+8, 2025-11-6 23:54 , Processed in 0.046728 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表