Skip to main content
Top

2019 | OriginalPaper | Chapter

2. Decision Making

Author : Ben Stephenson

Published in: The Python Workbook

Publisher: Springer International Publishing

Activate our intelligent search to find suitable subject content or patents.

search-config
loading …

Abstract

Most programs that solve interesting problems need to make decisions so that they can perform different actions in response to different input values. Python includes several decision making constructs, all of which evaluate a condition to determine whether or a statement (or group of statements) that is present in the program is executed or skipped. These decision making constructs include:
  • An if statement that allows a group of statements to be either executed or skipped
  • An if-else statement that causes exactly one of two groups of statements to execute
  • An if-elif-else statement that causes exactly one of several groups of statements to execute
  • An if-elif statement that causes at most one of several groups of statements to execute
All of these decision making constructs include a condition that is evaluate to determine which group of statements, if any, executes. The conditions can include relational operators and Boolean operators, both of which are discussed in this chapter. It ends with 28 exercises that allow the reader to put the concepts introduced in this chapter into practice.

Dont have a licence yet? Then find out more about our products and how to get one now:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Footnotes
1
Most programmers choose to use the same number of spaces each time they indent the body of an if statement, though Python does not require this consistency.
 
Metadata
Title
Decision Making
Author
Ben Stephenson
Copyright Year
2019
DOI
https://doi.org/10.1007/978-3-030-18873-3_2

Premium Partner