Skip to main content

Conditionals, Loops, and Some Other Statements

  • Chapter
  • First Online:
  • 20k Accesses

Abstract

By now, I’m sure you are getting a bit impatient. All right—all these data types are just dandy, but you can’t really do much with them, can you?

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   54.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   69.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    This will work only in a script, and not in an interactive Python session. In the interactive session, each statement will be executed (and print its contents) separately.

  2. 2.

    At least when we’re talking about built-in types—as you see in Chapter 9, you can influence whether objects you construct yourself are interpreted as true or false.

  3. 3.

    As Python veteran Laura Creighton puts it, the distinction is really closer to something vs. nothing, rather than true vs. false.

  4. 4.

    In fact, you can supply exec with two namespaces, one global and one local. The global one must be a dictionary, but the local one may be any mapping. The same holds for eval.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Magnus Lie Hetland

About this chapter

Cite this chapter

Hetland, M.L. (2017). Conditionals, Loops, and Some Other Statements. In: Beginning Python. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0028-5_5

Download citation

Publish with us

Policies and ethics