From the course: Python: Programming Efficiently
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Design efficient loops - Python Tutorial
From the course: Python: Programming Efficiently
Design efficient loops
- [Instructor] Looping constructs and the idea of iterating through data are so common and important in everyday programming that is worth taking the time to understand in depth how they work in Python. We begin by importing a number of Python modules that will come useful. Python loops are much simpler than in C. It's not just the syntax. As we saw, we don't have to take care of initializing a counter, updating it and checking its value to see if we need to drop out of the loop. This is because Python loops express a more general and simpler concept. We operate individually on the elements of a sequence. Let's take as an example the Fibonacci numbers. A sequence where each number is the sum of the two preceding ones. So it goes one, one, two, three, five, eight, 13, 21. Here it is as a Python list. Fibonacci numbers appear in many situations in nature, such as the branching of trees, the arrangement of leaves on a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Writing Python efficiently50s
-
(Locked)
Python vs. C4m 40s
-
(Locked)
Design efficient loops7m 3s
-
(Locked)
Comprehensions and generators6m 41s
-
(Locked)
Exploit Python collections7m 14s
-
(Locked)
Write Pythonic code6m 44s
-
(Locked)
Challenge: Analyze Olympic medalist data1m 20s
-
(Locked)
Solution: Analyze Olympic medalist data1m 33s
-
(Locked)
-
-
-
-