alien_color = ['green','yellow','red']
for color in alien_color:
if color == 'green':
print 'alien_color_%s: player to obtain five !'%color
elif color == 'yellow':
print 'alien_color_%s: player to obtain ten !' % color
else:
print 'alien_color_%s: player to obtain ten-five !' % color
try:
age = input('please value a integer:') #####input输入的是整数,raw_input输入的是字符串
if int(age) < 2:
print 'he is a baby!'
elif int(age) >= 2 and int(age) < 4:
print 'he is going!'
elif int(age)>= 4 and int(age) < 13:
print 'he is a teenager!'
elif int(age) >= 13 and int(age) < 65:
print 'he is a Middle-aged people!'
else:
print 'he is a old people!'
except:
print 'please value a integer!'
登录打招呼
user_name = ['admin', 'jack', 'bob', 'tom', 'mary']
for value in user_name:
value = raw_input('please value a user name:')
if value == 'admin':
print 'hello %s, would you like to see a status report?'% value
break
elif value not in user_name:
print 'error value'
break
else:
print 'hello %s, thank you for logging in again' % value
break
lists = [1,2,3,4,5,6,7,8,9]
for i in lists:
if i == 1:
print str(i) + 'st'
elif i == 2:
print str(i) + 'nd'
elif i == 3:
print str(i) + 'rd'
else:
print str(i) + 'th'

 
 

Python if-elif-else的更多相关文章

  1. python if elif else判断语句

    username = 'jack' password = ' _username = input('username') _password = input('password') if userna ...

  2. python if elif else 区别

    if data_ori=='医疗': # 医疗 df = pd.read_excel(path_apply + 'apply/YS_ZY_HZSQ_样例.xls', encoding='gbk', e ...

  3. python基础之条件控制与循环

    Python3 条件控制 Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. 计算机之所以能做很多自动化的任务,因为它可以自己做条件判断. 比如,输入用户 ...

  4. Python基础s14-day1

    2016年7月23日"Python基础s14-Day1" Python是什么? Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/),是一种面向对象.直译式 ...

  5. <转>Python学习推荐

    书籍推荐 基本了解: <<A Byte of Python>> (Python简明教程http://sebug.net/paper/python/) 网上有资源,两小时了解基本 ...

  6. ruby和Python简单对比

    前不久学了ruby,发现ruby和Python非常像,于是自个测试对比了下,测完了才知道网上有现成的……下面是测试结果   序列(包括列表和元组等)有分片的特点:可能会比较方便的提取其中特定元素,暂时 ...

  7. Day2 Python的运算符及三大语句控制结构

    Python的运算符 Python语言支持以下类型的运算符: 算术运算符 比较(关系)运算符 赋值运算符 逻辑运算符 位运算符 成员运算符 身份运算符 运算符优先级 Python的三大语句控制结构: ...

  8. python自动拉取备份压缩包并删除3天前的旧备份

    业务场景,异地机房自动拉取已备份好的tar.gz数据库压缩包,并且只保留3天内的压缩包文件,用python实现 #!/usr/bin/env python import requests,time,o ...

  9. Python 条件控制

    Python  条件控制 Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. 可以通过下图来简单了解条件语句的执行过程: if 语句 Python中if语 ...

  10. Python之旅:流程控制

    流程控制之if...else 每条if语句的核心都是一个值为True或False的表达式,这种表达式被称为条件测试. Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定 ...

随机推荐

  1. xml简介与使用

    Xml是什么? XML:可扩展标记语言 1.与HTML相似,HTML注重页面·展示 2.xml注重于数据的保存 3.无需预编译 4.符合w3c的标准 可扩展:可以自定义 标记:计算机所能认知的信息符号 ...

  2. Mine_hibernate

    1. __z知识点\整理_归纳 ==> "ZC_归纳.txt" 和 "ZC_归纳__12_用Eclipse开发hibernate.txt" 2.

  3. JavaScript 打印控件

    JavaScript 打印控件 github地址 https://github.com/DoersGuild/jQuery.print 使用前需要引入jQuery $("#mapDiv&qu ...

  4. vue2 遇到的问题汇集ing

    1 .子路由 { path: '/order-list', //订单列表 name: "order-list", component(resolve) { require.ensu ...

  5. Spring获取bean的几种方式

    工作中需要对一个原本加载属性文件的工具类修改成对数据库的操作当然,ado层已经写好,但是需要从Spring中获取bean,然而,工具类并没有交给Spring来管理,所以需要通过方法获取所需要的bean ...

  6. Referenced file contains errors (http://www.springframework.org/schema/aop/spring-aop-3.0.xsd). For more information, right click on the message in th

    XML code<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC &q ...

  7. 关于pytest的一些问题

    一. 测试模块内部使用fixture和测试模块调用外部公共的fixture 1. unittest框架下的测试用例模块 from selenium import webdriver import un ...

  8. Educational Codeforces Round 23D

    给n个数求每个子区间的价值,区间的价值是最大值-最小值 套路题= =,分别算最大值和最小值的贡献,用并查集维护,把相邻点连一条边,然后sort,求最大是按边价值(两个点的最大价值)小的排,求最小是按最 ...

  9. SVN与Git优缺点比较

    1.SVN优缺点优点: 1. 管理方便,逻辑明确,符合一般人思维习惯. 2. 易于管理,集中式服务器更能保证安全性. 3. 代码一致性非常高. 4. 适合开发人数不多的项目开发. 缺点: 1. 服务器 ...

  10. Could not publish server configuration for Tomcat v6.0 Server at localhost.错误问题解决

    经常在使用tomcat服务器的时候 总会发生一些莫名其妙的错误. 就像下面这个错误: 在配置文件中存在多个/MyWeb的配置,导致不能发布服务. 错误信息: Could not publish ser ...