Go With the Flow
来源:互联网 发布:group by 多个字段知乎 编辑:程序博客网 时间:2024/06/14 13:52
(This course assumes familiarity with the material presented in Unit 1: Python Syntaxand Unit 2: Strings & Console Output. From here on out, take for granted that each new course assumes knowledge of the material presented in the previous courses.)
You may have noticed that the Python programs we've been writing so far have had sort of one-track minds. They compute the sum of two numbers or print
something to the console, but they don't have the ability to pick one outcome over another—say, add two numbers if their sum is less than 100, or instead print
the numbers to the console without adding them if their sum is greater than 100.
Control flow allows us to have these multiple outcomes and to select one based on what's going on in the program. Different outcomes can be produced based on user input or any number of factors in the program's environment. (The environment is the technical name for all the variables—and their values—that exist in the program at a given time.)
'''def clinic(): print "You've just entered the clinic!" print "Do you take the door on the left or the right?" answer = raw_input("Type left or right and hit 'Enter'.").lower() if answer == "left" or answer == "l": print "This is the Verbal Abuse Room, you heap of parrot droppings!" elif answer == "right" or answer == "r": print "Of course this is the Argument Room, I've told you that already!" else: print "You didn't pick left or right! Try again." clinic()'''##上面采用的是递归。递归的效率比较低。改为循环def clinic(): print "You've just entered the clinic!" print "Do you take the door on the left or the right?" while True: answer = raw_input("Type left or right and hit 'Enter'." ).lower() if answer == "left" or answer == "l": print "This is the Verbal Abuse Room, you heap of parrot droppings!" break elif answer == "right" or answer == "r": print "Of course this is the Argument Room, I've told you that already!" break else: print "You didn't pick left or right! Try again."clinic()
- Go With the Flow
- Not go with the wind but C++
- Understanding the GitHub Flow
- sip call flow with prack
- Rollback button with the property 'immediate' set to 'true' doesn't rollback values from a task flow.
- Go forward with Linux
- go with dream
- A year with Go
- GO-SRS with TravisCI
- mac with go
- Using Go with Redis
- Building Microservices with Go
- My interest is the rules/ways to implement, go and insist with interest!!!
- 读书笔记:Mastering the game of Go with deep neural networks and tree search
- Mastering the game of Go with deep neural networks and tree search 中文版来了
- Mastering the game of Go with deep neural networks and tree search
- 论文笔记:Mastering the game of Go with deep neural networks and tree search
- [git] HOWTO work with git flow
- ViewPager初识
- strcpy函数实现
- 享受Code::Blocks编辑快感的几个关键
- make命令解析
- C. Building Permutation
- Go With the Flow
- ZOJ 1025 Wooden Sticks
- (linux) 让你的 shell 脚本更强大的10个工具
- Compare Closely!
- 玩骰子的儿童(赫拉克利特)
- 常用的一些排序算法(C++实现)
- 新手学PHP两个月后的体会总结
- 关于“绕坐标轴的旋转”和“鼠标控制物体的旋转”(一)
- Test Precisely and Concretely