python 条件,循环
来源:互联网 发布:正规矩阵奇异值 编辑:程序博客网 时间:2024/06/03 22:55
一些例子
#!/usr/bin/python#!/usr/bin/env python3print "-----------if application--------"flag = Falsename = 'UMR'if name == 'xiaomai': print welcome xiaomai' flag = Trueelse: print nameprint "-----------while application"numbers = [12,13,14,15,16,17,57]while len(numbers) > 0: number = numbers.pop() if (number % 2 ==0): print number else: print "that is odd number"print "-----------for application-----------"print "eg of 'for'1"for letter in 'python': print 'Letter\n', letterfruits = ['a','b','c']for fruit in fruits: print fruitprint("eg of for 2")idol = ['UMR1','UMR2','UMR3','UMR4']i=0for index in range(len(idol)): print(idol[i]+"is the best idol") i=i+1print "-----------rock, paper, scissors------"import randomstart = raw_input('Are you ready for the game? Y/N')while (start == 'Y'): print 'okay lets begin' s = int(random.randint(1,3)) if s == 1: ind = 'rock' elif s == 2: ind = 'paper' elif s == 3: ind = 'scissors' m = raw_input('Input rock/paper/scissors or endgame') if (m == ind): print 'this is a tie' elif (m == 'paper'and ind == 'rock') or (m == 'rock' and ind == 'scissors') or (m == 'scissors' and ind == 'paper'): print 'congraduations you win ' elif (m == 'rock'and ind == 'paper') or (m == 'paper' and ind == 'scissors') or (m == 'scissors' and ind == 'rock'): print 'what a pity, try again' elif (m == 'endgame'): break else : print 'Please input rock/paper/scissors or endgame'print('-------BMI index------')height=float(input('Please input your height(cm): '))weight=float(input('Please input your weight(kg): '))BMI=height/weight**2if BMI<18.5: print('too light')else: print('too heavy')
阅读全文
0 0
- Python:循环、条件判断
- Python:条件和循环
- python条件判断、循环
- python 条件、循环
- python 条件,循环
- python的循环条件
- python条件、循环、终止
- python条件与循环
- Python 条件和循环
- python中的条件和循环
- python条件及循环语句
- python 条件判断和循环
- python 条件判断与循环
- Python学习笔记:条件、循环
- Python(条件判断和循环)
- python之条件、循环语句
- python条件判断与循环
- Python-条件判断和循环
- 并查集入门
- matplotlib学习之scatter()函数--颜色印射
- comma.ai实践2
- cordova Ionic 和cordova的区别是什么(项目总结)
- Linux下编译安装python3
- python 条件,循环
- Linux 的Apache服务之https与网页重写
- sftp上传文件
- org.springframework.dao.InvalidDataAccessApiUsageException: (错误记录,级联删除错误)
- 多目标进化算法(MOEAs)概述
- Hive2.0函数大全(中文版)
- iOS 关于不死后台
- 根目录下修改.babelrc文件
- 最长连续回文串(Longest Palindromic Substring) 的 O(n)解法