Check out a free preview of the full Practical Guide to Python course

The "Practical Applications Practice" Lesson is part of the full, Practical Guide to Python course featured in this preview video. Here's what you'd learn in this lesson:

Nina walks the students through the Practical Applications practice.

Preview
Close

Transcript from the "Practical Applications Practice" Lesson

[00:00:00]
>> Now we talked about some practical applications of Python as well. We talked about list comprehensions. Let's say that we wanted to create a list of only odd numbers between zero and 100 using a list comprehension. We can do that by using range to get the numbers from 0 to 99 in this case and add them to our list comprehension only if that number that is generated is divisible by 2.

[00:00:34]
You can also, use a set comprehension or a dictionary comprehension. Those are outside of the scope of the course but they are included on the course website for you to look at. Slicing is another important concept in Python. Let's say I had a list that looked like this with individual characters in it.

[00:00:59]
I can take a look at the length. I could also ask for slices of my list. So for example, the slice from four to six. If I wanted to exclude that value, I would get the same results because by default, if you don't provide the value, it goes all the way to the end.

[00:01:26]
If you don't provide a start value, it goes all the way to the beginning. Passing in no arguments at all is a quick shortcut to get a copy of a list in Python. You can also use the zip function to take two lists and combine them together. This is especially useful when you are converting between types.

[00:01:50]
So I recommend that you go through the converting between types exercise on your own when you have time.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now