• Keine Ergebnisse gefunden

Sample Tasks

Im Dokument Basics of CS (Seite 83-89)

Sample Task 1

The following function is supposed to return True if the given number is divisible by 9 and False otherwise. Fill in lines 2 and 5.

1 defbynine(x):

2 if :

3 returnFalse

4 else:

5 return

Sample Task 2

What is the output of the following code?

1 x = 2 Sample Task 3

What is the output of the following code 1 x = [2 * iforiin range(0, 5, 2)]

2 x.pop() 3 print(x)

Sample Task 4

The following function is supposed to create, from a list with an even number of elements, a list in which two consecutive elements are added, such that, e.g., [1, 2, 3, 4] results in [3, 7]. A list with an odd number of elements results in a list that only contains -1. Fill out lines 3 and 5.

1 defaddlist(liste):

2 neueliste = []

3 if :

4 return[-1]

5 foriin range( ):

6 neueliste.append(liste[i - 1] + liste[i]) 7 returnneueliste

Sample Task 5

What is the output of the following code?

1 x = [iforiin range(1, 9)]

2 y = []

3 k = 0 4 whileTrue:

5 ifk > 6orTrue:

1, len(liste), 2

[]

Basics of Computer Science for Human Medicine – numpy, matplotlib Autumn 2021 Böckenhauer, Komm 25 / 25

Sample Tasks

Sample Task 1

The following function is supposed to return True if the given number is divisible by 9 and False otherwise. Fill in lines 2 and 5.

1 defbynine(x):

2 if :

3 returnFalse

4 else:

5 return

Sample Task 2

What is the output of the following code?

1 x = 2 Sample Task 3

What is the output of the following code 1 x = [2 * iforiin range(0, 5, 2)]

2 x.pop() 3 print(x)

Sample Task 4

The following function is supposed to create, from a list with an even number of elements, a list in which two consecutive elements are added, such that, e.g., [1, 2, 3, 4] results in [3, 7]. A list with an odd number of elements results in a list that only contains -1. Fill out lines 3 and 5.

1 defaddlist(liste):

2 neueliste = []

3 if :

4 return[-1]

5 foriin range( ):

6 neueliste.append(liste[i - 1] + liste[i]) 7 returnneueliste

Sample Task 5

What is the output of the following code?

1 x = [iforiin range(1, 9)]

2 y = []

3 k = 0 4 whileTrue:

5 ifk > 6orTrue:

1, len(liste), 2

[]

Sample Tasks

Sample Task 1

The following function is supposed to return True if the given number is divisible by 9 and False otherwise. Fill in lines 2 and 5.

1 defbynine(x):

2 if :

3 returnFalse

4 else:

5 return

Sample Task 2

What is the output of the following code?

1 x = 2 Sample Task 3

What is the output of the following code 1 x = [2 * iforiin range(0, 5, 2)]

2 x.pop() 3 print(x)

Sample Task 4

The following function is supposed to create, from a list with an even number of elements, a list in which two consecutive elements are added, such that, e.g., [1, 2, 3, 4] results in [3, 7]. A list with an odd number of elements results in a list that only contains -1. Fill out lines 3 and 5.

1 defaddlist(liste):

2 neueliste = []

3 if :

4 return[-1]

5 foriin range( ):

6 neueliste.append(liste[i - 1] + liste[i]) 7 returnneueliste

Sample Task 5

What is the output of the following code?

1 x = [iforiin range(1, 9)]

2 y = []

3 k = 0 4 whileTrue:

5 ifk > 6orTrue:

1, len(liste), 2

[]

Basics of Computer Science for Human Medicine – numpy, matplotlib Autumn 2021 Böckenhauer, Komm 25 / 25

Sample Tasks

Sample Task 1

The following function is supposed to return True if the given number is divisible by 9 and False otherwise. Fill in lines 2 and 5.

1 defbynine(x):

2 if :

3 returnFalse

4 else:

5 return

Sample Task 2

What is the output of the following code?

1 x = 2 Sample Task 3

What is the output of the following code 1 x = [2 * iforiin range(0, 5, 2)]

2 x.pop() 3 print(x)

Sample Task 4

The following function is supposed to create, from a list with an even number of elements, a list in which two consecutive elements are added, such that, e.g., [1, 2, 3, 4] results in [3, 7]. A list with an odd number of elements results in a list that only contains -1. Fill out lines 3 and 5.

1 defaddlist(liste):

2 neueliste = []

3 if :

4 return[-1]

5 foriin range( ):

6 neueliste.append(liste[i - 1] + liste[i]) 7 returnneueliste

Sample Task 5

What is the output of the following code?

1 x = [iforiin range(1, 9)]

2 y = []

3 k = 0 4 whileTrue:

5 ifk > 6orTrue:

1, len(liste), 2

[]

Sample Tasks

Sample Task 1

The following function is supposed to return True if the given number is divisible by 9 and False otherwise. Fill in lines 2 and 5.

1 defbynine(x):

2 if :

3 returnFalse

4 else:

5 return

Sample Task 2

What is the output of the following code?

1 x = 2 Sample Task 3

What is the output of the following code 1 x = [2 * iforiin range(0, 5, 2)]

2 x.pop() 3 print(x)

Sample Task 4

The following function is supposed to create, from a list with an even number of elements, a list in which two consecutive elements are added, such that, e.g., [1, 2, 3, 4] results in [3, 7]. A list with an odd number of elements results in a list that only contains -1. Fill out lines 3 and 5.

1 defaddlist(liste):

2 neueliste = []

3 if :

4 return[-1]

5 foriin range( ):

6 neueliste.append(liste[i - 1] + liste[i]) 7 returnneueliste

Sample Task 5

What is the output of the following code?

1 x = [iforiin range(1, 9)]

2 y = []

3 k = 0 4 whileTrue:

5 ifk > 6orTrue:

1, len(liste), 2

[]

Basics of Computer Science for Human Medicine – numpy, matplotlib Autumn 2021 Böckenhauer, Komm 25 / 25

Sample Tasks

Sample Task 1

The following function is supposed to return True if the given number is divisible by 9 and False otherwise. Fill in lines 2 and 5.

1 defbynine(x):

2 if :

3 returnFalse

4 else:

5 return

Sample Task 2

What is the output of the following code?

1 x = 2 Sample Task 3

What is the output of the following code 1 x = [2 * iforiin range(0, 5, 2)]

2 x.pop() 3 print(x)

Sample Task 4

The following function is supposed to create, from a list with an even number of elements, a list in which two consecutive elements are added, such that, e.g., [1, 2, 3, 4] results in [3, 7]. A list with an odd number of elements results in a list that only contains -1. Fill out lines 3 and 5.

1 defaddlist(liste):

2 neueliste = []

3 if :

4 return[-1]

5 foriin range( ):

6 neueliste.append(liste[i - 1] + liste[i]) 7 returnneueliste

Sample Task 5

What is the output of the following code?

1 x = [iforiin range(1, 9)]

2 y = []

3 k = 0 4 whileTrue:

5 ifk > 6orTrue:

1, len(liste), 2

[]

Thanks

Im Dokument Basics of CS (Seite 83-89)

ÄHNLICHE DOKUMENTE