GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Notizen

for loop over a function

Sofia Sarachu Spanisch 1 Seite

Inhalt der Notizen (1)

Seite 1

for loop over a function

For Loop Over a Function

A for loop can also be used to execute a function multiple times. For example, below we are executing celsius_to_kelvin three times since there are three items in the iterating list:

def celsius_to_kelvin(cels):

return cels + 273.15

for temperature in [9.1, 8.8, -270.15]:

print(celsius_to_kelvin(temperature))

The output of that would be:

282.25

281.95

3.0

So, in the first iteration celsius_to_kelvin(9.1) was executed, in the second celsius_to_kelvin(8.8) and in the third celsius_to_kelvin(-270.15).

Contenido del curso

Contenido del curso

Descripción general

Notas

Anuncios

Valoraciones

Herramientas de aprendizaje

Informationen

Beschreibung
Notiz am for loop over a function, erstellt von Sofia Sarachu am 29/10/2024.
Erstellt von
Sofia Sarachu
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck