filmov
tv
Lesson 9 - For Loop in Python | Iterating over a List in Python | Python Tutorial for Beginners

Показать описание
Looping Through Lists in Python | Python Tutorial for Beginners | learn python - full course for beginners windows 10
Welcome to lesson 9. In this class, we are gonna learn how to loop through a list by using a for loop in Python.
Lesson 9 Exercises
1. Make a list of anything like cars, food, desserts, or animals. By using a for loop, print each item on the screen.
2. Use the same list you created in Exercise 1 and by using a for loop, print a statement for each item. Example:
Carrot cake is one of my favorite desserts!
3. Use the same list and for loop from Exercise 1 but add a general message that should only be printed once. That message should relate to all the items in the list. For example, if the list stores desserts, the last ,message should be something like:
All these desserts are delicious but consuming too much sugar is not healthy!
4. Repeat all three exercise above but this time use a different list.
Answers for Lesson 8 Exercises
#1.
movies = ['Venom', 'Greenland', 'Titanic', 'Robocop']
print('I have watched ' + str(len(movies)) + ' movies in the last 6 months.')
#2.
print(sorted(movies))
print(movies)
print(movies)
#3.
print(movies)
print(movies)
----------------
Song: Valence - Infinite [NCS Release]
Music provided by NoCopyrightSounds
Welcome to lesson 9. In this class, we are gonna learn how to loop through a list by using a for loop in Python.
Lesson 9 Exercises
1. Make a list of anything like cars, food, desserts, or animals. By using a for loop, print each item on the screen.
2. Use the same list you created in Exercise 1 and by using a for loop, print a statement for each item. Example:
Carrot cake is one of my favorite desserts!
3. Use the same list and for loop from Exercise 1 but add a general message that should only be printed once. That message should relate to all the items in the list. For example, if the list stores desserts, the last ,message should be something like:
All these desserts are delicious but consuming too much sugar is not healthy!
4. Repeat all three exercise above but this time use a different list.
Answers for Lesson 8 Exercises
#1.
movies = ['Venom', 'Greenland', 'Titanic', 'Robocop']
print('I have watched ' + str(len(movies)) + ' movies in the last 6 months.')
#2.
print(sorted(movies))
print(movies)
print(movies)
#3.
print(movies)
print(movies)
----------------
Song: Valence - Infinite [NCS Release]
Music provided by NoCopyrightSounds