Python1:if / while / for...in / break /continue
来源:互联网 发布:流媒体服务软件 编辑:程序博客网 时间:2024/05/27 20:14
1.使用if语句
#if.pynumber = 23;guess = int(raw_input('Enter an integer:'));if guess == number: print 'congratulations, u guessed it'; print 'but u dont win any prize';elif guess < number: print 'no,it is a little heigher than that';else: print 'no,it is a little lower than that';print 'Done';
2.使用while语句
#while.pynumber = 23;running = 1;while running: guess = int(raw_input('Enter an integer:')); if guess == number: print 'congratulations, u guessed it'; running = 0; elif guess < number: print 'terribly,it is a little lower than that'; else: print 'terribly,it is a little heigher than that';else: print 'that while loop is over';print 'Done';
3.使用for...in语句
#for.pyfor i in range(1,5): print i;else: print 'the for loop is over';
4.使用break语句
#break.pywhile True: s = raw_input('Enter something:'); if s == 'quit': break; print 'Length of the string is : ' , len(s);print 'Done';
5.使用Continue语句
continue语句用来告诉Python条股当前循环块中的剩余语句,然后继续执行下一轮循环。#break.pywhile True: s = raw_input('Enter something:'); if s == 'quit': break; if len(s) < 3: continue; print 'Input is of sufficient length';
阅读全文
0 0
- Python1:if / while / for...in / break /continue
- if+while+for+continue+break
- if/for/while/until/break/continue
- swift中流程控制:for in、while、do while、if、switch、continue、break...
- Python学习--控制语句:if, while, for, break, continue
- python基础语法之if,else,for,while,continue,break
- 循环语句if(){}else{}、if(){}else if(){}...else{}、do{}while()、for(){}、with(){}break/continue语句
- C语言中流程控制语句(if,switch,for,while,do-while,continue,break,return)
- Java语言基础(程序流程控制-if、switch、for、while、do while、break、continue)
- 分支语句(if,switch case)、循环(for,while,do while)、continue、break、随机数
- if,continue,break,while,do-while, switch,return,foreach,for等条件语句的使用
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select
- 黑马程序员——常用语句总结(for if..else do..while break..continue)
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select
- GoodZhang在学Python(三)--控制流if while for break continue
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select
- Mybatis中#{}和${}区别
- JavaScript进阶:js操作符类型转换
- Think in Java笔记(一)
- Repeater+AspNetPager+Ajax留言板
- IOS基础--CG函数篇
- Python1:if / while / for...in / break /continue
- (全站式导航)
- stm32 按键操作
- 字节对齐
- 展视互动获得正确接口网址
- Xamarin.Forms 用户界面——颜色
- 合并两个有序数组
- 个人的一些前端思考
- Xamarin.Forms 用户界面——控件