Iterating using For loop | Syntax

Publicado el: 04 marzo 2019
en el canal de: EdYoda
266
4

For more courses visit : https://www.edyoda.com/

In this video we will discuss how to write the for loop to iterate over a collection of element and perform certain operation on every element. We will also discuss the built in range() function to generate series of numbers.

Practice Problem:

1) Write a Python program that sums all of the first integers, the second integers, and the third integers, outputting the resulting sums all.

if the input is

[2, 5,7]

[3, 6, 10]

[1, 2, -3]

[2, 4, 1]

Then the output should be

[8, 17, 15]

2) v is a list containing numbers. Write Python code to find and print the highest two values in v. If the list contains only one number, print only that number. If the list is empty, print nothing. For example,

v = [ 7, 3, 1, 5, 10, 6 ]

Output l = [7,10]


En esta página del sitio puede ver el video en línea Iterating using For loop | Syntax de Duración hora minuto segunda en buena calidad , que subió el usuario EdYoda 04 marzo 2019, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 266 veces y le gustó 4 a los espectadores. Disfruta viendo!