Data Structure Quiz 03

Python Coding Quiz - Data Structures & Operations

Python Coding Quiz - Data Structures & Operations

Answer the coding questions below by selecting all applicable options:

Time Remaining: 03:20

1. Which of the following code snippets correctly appends 4 to a list my_list? (Select all that apply)

A) my_list.append(4) B) my_list.insert(-1, 4) C) my_list += [4] D) my_list.add(4)

2. Which of the following code snippets retrieves the keys from a dictionary my_dict? (Select all that apply)

A) my_dict.keys() B) list(my_dict.keys()) C) my_dict.getKeys() D) my_dict["keys"]

3. Which of the following code snippets removes duplicates from a list my_list? (Select all that apply)

A) my_list = list(set(my_list)) B) my_list.remove_duplicates() C) my_list = [*set(my_list)] D) my_list.unique()

4. Which of the following code snippets creates a set with elements 1, 2, and 3? (Select all that apply)

A) my_set = {1, 2, 3} B) my_set = set([1, 2, 3]) C) my_set = {1: 2, 3} D) my_set = set({1, 2, 3})

5. Which of the following code snippets correctly checks if 5 is in the list my_list? (Select all that apply)

A) if 5 in my_list: B) if my_list.contains(5): C) if 5 in my_list[]: D) if 5 in list(my_list):