Skip to Content
Learn Python by Building Data Science Applications
book

Learn Python by Building Data Science Applications

by Philipp Kats, David Katz
August 2019
Beginner
482 pages
12h 56m
English
Packt Publishing
Content preview from Learn Python by Building Data Science Applications

Loops and Other Compound Statements

In the previous chapter, we learned how to create and operate on data structures. Now, let's discuss how to operate on them effectively.

We will first cover loops—a special type of compound statement (code that compounds other code, just like functions)—that allows the same code to be run over and over—any number of times, or even indefinitely. After loops, we will discuss if-else statements—logical forks that allow us to split code execution based on test results. Finally, we will cover two less popular, but still very useful, clauses—try, which helps to save the day if something goes wrong (an error is raised) within the code, and with , which helps to close the context safely (for example, close the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Data Science

Python for Data Science

Yuli Vasiliev
Introduction to Machine Learning with Python

Introduction to Machine Learning with Python

Andreas C. Müller, Sarah Guido

Publisher Resources

ISBN: 9781789535365Supplemental Content