SAQ 4.1

SAQ 4.1

University

17 Qs

quiz-placeholder

Similar activities

One Direction

One Direction

2nd Grade - University

13 Qs

All about me

All about me

KG - Professional Development

15 Qs

Martial arts

Martial arts

KG - University

20 Qs

Pengenalan Jurusan Accounting 2020

Pengenalan Jurusan Accounting 2020

University

20 Qs

Driver's Ed Chapter 5

Driver's Ed Chapter 5

8th Grade - Professional Development

20 Qs

Eclipse

Eclipse

KG - Professional Development

20 Qs

Product Quiz

Product Quiz

University

15 Qs

Dhoni

Dhoni

KG - Professional Development

20 Qs

SAQ 4.1

SAQ 4.1

Assessment

Quiz

Other

University

Hard

Created by

Parker Gaston

FREE Resource

17 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Using a for loop, we can iterate through the items of a Python list in either a "by item" or a "by index" manner.

True

False

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

This function is supposed to sum all of the elements in a list of numbers. Which of the following should replace the comment line?

def sumList(myList):

acc = 0

# what goes here?

acc = acc + myList[i]

return acc

 

for i in range(len(myList)):

for acc in myList:

 

for myList:

 

for x in myList:

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Assuming the parameter myList is a list of integers between zero and 100, what does this function return?

def foo(myList):

  x = -1

  for y in myList:

    if y > x:

      x = y

 

  return x

 

The second largest value in myList

 

The smallest value in myList

 

The second smallest value in myList

 

The largest value in myList

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of this code?

myList = [-1, 4, 5, -3, 8, 4, 1, 0, -3, 0]

acc = 0

for i in myList:

  if i > 0:

    acc = acc + i

acc

 

-7

22

 

7

 

45

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is output by the following code?

changeList = [1, 2, "buckle my shoe", 3, 4, "shut the door"]

changeList[2] = "the sky is blue"

changeList

 

'the sky is blue'

[1, 2, "the sky is blue", 3, 4, "shut the door"]

 

[1, 'the sky is blue', "buckle my shoe", 3, 4, 'shut the door']

 

TypeError:object does not support item assignment

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Python provides the _________ function to create a list from a range or string.

list

append

insert

 

[ ]

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The __________ list method removes and returns the last item in a list.

remove

reverse

count

pop

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?