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]
In questa pagina del sito puoi guardare il video online Iterating using For loop | Syntax della durata di ore minuti seconda in buona qualità , che l'utente ha caricato EdYoda 04 marzo 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 266 volte e gli è piaciuto 4 spettatori. Buona visione!