Computer Science
Which of the following will delete key-value pair for key = “Red” from a dictionary D1 ?
- delete D1("Red")
- del D1["Red"]
- del.D1["Red"]
- D1.del["Red"]
Python Dictionaries
1 Like
Answer
del D1["Red"]
Reason — The syntax to delete a key-value pair from a dictionary in Python is : del dictionary_name[key]
. Therefore, according to this syntax, del D1["Red"]
is correct statement."
Answered By
2 Likes
Related Questions
In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and another table, Beta has degree 3 and cardinality 5, what will be the degree and cardinality of the Cartesian product of Alpha and Beta?
- 5, 3
- 8, 15
- 3, 5
- 15, 8
Riya wants to transfer pictures from her mobile phone to her laptop. She uses Bluetooth Technology to connect two devices. Which type of network will be formed in this case?
- PAN
- LAN
- MAN
- WAN
Consider the statements given below and then choose the correct output from the given options:
pride = "#G20 Presidency" print(pride[-2:2:-2])
- ndsr
- ceieP0
- ceieP
- yndsr
Which of the following statement(s) would give an error during execution of the following code ?
tup = (20, 30, 40, 50, 80, 79) print(tup) #Statement 1 print(tup[3] + 50) #Statement 2 print(max(tup)) #Statement 3 tup[4] = 80 #Statement 4
- Statement 1
- Statement 2
- Statement 3
- Statement 4