Search Header Logo

Understanding Python Dictionaries

Authored by Clarkston Ellerby

Computers

11th Grade

Used 1+ times

Understanding Python Dictionaries
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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)`

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?