Understanding Python Dictionaries

Understanding Python Dictionaries

11th Grade

10 Qs

quiz-placeholder

Similar activities

Questions for LMS & HMM Briefing

Questions for LMS & HMM Briefing

2nd - 11th Grade

10 Qs

Student Information Needed for Program

Student Information Needed for Program

9th - 12th Grade

6 Qs

Animation History

Animation History

5th - 12th Grade

8 Qs

Boolean Logic

Boolean Logic

9th - 12th Grade

10 Qs

Web Design: 1-3 Browsers

Web Design: 1-3 Browsers

11th Grade

8 Qs

Subclass/Subclass

Subclass/Subclass

11th Grade

11 Qs

AP CSP Unit 4

AP CSP Unit 4

9th - 12th Grade

10 Qs

Code.org Unit 4 Principles

Code.org Unit 4 Principles

9th - 12th Grade

10 Qs

Understanding Python Dictionaries

Understanding Python Dictionaries

Assessment

Quiz

Computers

11th Grade

Hard

Created by

Clarkston Ellerby

Used 1+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to create a dictionary in Python with the keys "name", "age", and "courses"?

`student = {"name": "John", "age": 18, "courses": ["Math", "Science", "History"]}`

`student = ["name": "John", "age": 18, "courses": ["Math", "Science", "History"]]`

`student = ("name": "John", "age": 18, "courses": ["Math", "Science", "History"])`

`student = {"name": "John", "age": 18, "courses": "Math, Science, History"}`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you print the entire dictionary named `student` in Python?

`print student`

`print(student)`

`echo(student)`

`display(student)`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct way to access the "name" key from the `student` dictionary?

`student["name"]`

`student.name`

`student->name`

`student.get("name")`

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you access the list of courses from the `student` dictionary?

`student["courses"]`

`student.courses`

`student->courses`

`student.get("courses")`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to add a new key-value pair for "grade" in the `student` dictionary, where "Math" is the course and 90 is the grade?

`student["grade"] = {"Math": 90}`

`student["grade"] = "Math": 90`

`student.grade = {"Math": 90}`

`student.add("grade", {"Math": 90})`

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If you want to print only the student's age from the `student` dictionary, which of the following would you use?

`print(student["age"])`

`print(student.age)`

`print(student->age)`

`print(student.get("age"))`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements will correctly update the student's age to 19 in the `student` dictionary?

`student["age"] = 19`

`student.age = 19`

`student->age = 19`

`student.set("age", 19)`

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?