Iterating using For loop | Syntax

Veröffentlicht am: 04 März 2019
auf dem Kanal: 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]


Auf dieser Seite können Sie das Online-Video Iterating using For loop | Syntax mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer EdYoda 04 März 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 266 Mal angesehen und es wurde von 4 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!