- Repeating code over and over again,…via a construct known as a loop,…is also a fairly common scenario in programming.…Python provides a couple of ways of doing that,…which we're going to take a look at now.…So in your editor open up loops_start.pui…And you can see that I've got…a stubbed out function here named main…and a variable named x, which I'm initializing to zero.…So, let's start by taking a look at the while loop.…To write a while loop, I use the keyword while,…and then I give it a condition.…
So, I'll write while x is less than five…and then my colon.…And again you can see that the code is being indented…under the colon there.…And I'll write print x and then x equals x plus one.…A while loop executes a block of code…while a particular condition evaluates true.…So, while x is less than five,…we're going to print the value of x,…and then we're going to increment x by one.…Some languages, like C, provide…a whole bunch of ways of doing loops.…
Python likes to keep things simple.…It's only got two ways of doing loops, while and for.…
- Installing Python
- Choosing an editor or IDE
- Working with variables and expressions
- Writing loops
- Using the date, time, and datetime classes
- Reading and writing files
- Fetching internet data
- Parsing and processing HTML
Skill Level Beginner
Programming Foundations: Design Patterns (2013)with Elisabeth Robson2h 19m Intermediate
1. Getting Started
2. Python Basics
3. Working with Dates and Time
4. Working with Files
5. Working with Web Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.