Funktionen Flashcards

1
Q

Sind Variablen innerhalb einer Funktion außerhalb sichtbar?

A

nein, alle innerhalb einer Funktion definierten Variablen sind lokal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Wie sehen Funktionen aus?

A
def funktionsname(parameter1, parameter2,...):
Anweisung 
return
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Wie sieht eine Funktion mit optionalen Parameter aus?

A
def funktionsname(param1, param2=defaultwert2, param3=defaultwert3):
Anweisung 
return
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Wie können Funktionen beliebige Anzahl an Parametern haben?

A

hinterster Paramter trägt einen * vor seinem Namen, bekommt alle überzähligen Werte zugewiesen in Form eines Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Wie wird eine Funktion aufgerufen?

A

print(funktionsname(wert1, wert2,…)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Können Mathematik-Funktionen benutzt werden?

A

Ja, manche müssen nciht importiert werden.

Mathematik-Funktionsbibliotheken müssen importiert werden mit import math

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Wie kann man Zufallszahlen generieren?

A

zufallsfließkommazahl: random.random()

Zufallsganzzahl: random. randrange(start, stop)

Zufallsganzzahl: random.randint(start, stop)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Wie können Module importiert werden?

A

alle Funktionen aus math: import math

alle Funktionen aus math mit Globalzugriff: from math import *

einzelne Funktionen eines Moduls mit Globalzugriff: from math import sin, cos

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Welche vordefinierten Funktionen gibt es in Python?

A

max
min
round(x): rundet x auf Ganzzahl
round(x, n): rundet x auf n Nachkommastellen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Wofür sind Funktionen?

A

für Abruf bestimmter Parameter (zB sortieren)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly