错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Conditional and Repetitive Execution

  • Sinan Kalkan,
  • Onur T. Şehitoğlu,
  • Göktürk Üçoluk

摘要

Many circumstances require a program’s execution (i) to change its flow based on the truth value of a condition, or (ii) to repeat a set of steps for a certain number of times or until a condition is no longer true. These two kinds of actions are crucial components of programming solutions, for which Python provides several alternatives. As we will see in this chapter, some of these alternatives are compound statements, while others are expressions. Asking (mostly) mathematical questions that have Boolean-type answers and taking some actions (or not) based on the Boolean answers are fundamental in designing algorithms. This is so vital that there is no programming language that does not provide conditional execution.