设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
123
返回列表 发新帖
楼主: crossin先生
打印 上一主题 下一主题

【Python 第24课】 if的嵌套

[复制链接]

0

主题

2

好友

72

积分

注册会员

Rank: 2

21#
发表于 2018-4-6 10:58:27 |只看该作者
这是看了看大家的代码,得到的灵感,还可以练练函数~
  1. def quadrant(x,y):   
  2.     if x>0:
  3.         if y>0:
  4.             print('First quadrant')
  5.         elif y<0:
  6.             print('Fourth quadrant')
  7.         else:
  8.             print('The number is in active abscissa')
  9.     elif x<0:
  10.         if y>0:
  11.             print('Second quadrant')
  12.         elif y<0:
  13.             print('Third quadrant')
  14.         else:
  15.             print('The number is in negative abscissa')
  16.     else:
  17.         if y>0:
  18.             print('The number is in active ordinate')
  19.         elif y<0:
  20.             print('The number is in negative ordinate')
  21.         else:
  22.             print('The center is waiting for you!!!')
  23. x=eval(input('please enter the abscissa'))
  24. y=eval(input('please enter the ordinate'))
  25. quadrant(x,y)
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-5 07:36 , Processed in 0.023635 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部