Computer Science, asked by s1044mnivedha22650, 2 days ago

Differentiate following functions with example: 8

a. del & clear

b. append & extend

c. pop & popitem

d. max & min​

Answers

Answered by thanujailayaraja10
0

a)In Python dictionary, del keyword is used to delete a particular element. The clear( ) function is used to delete all the elements in a dictionary. To remove the dictionary, we can use del keyword with dictionary name.

Dict={‘Roll No’: 12001, ‘SName’: ‘Meena’ , ‘Mark1’: 98, ‘Mar12’: 86}

print(“Dictionary elements before deletion: \n” , Dict) del Dict[‘Mark1’]

# Deleting a particular element Dict.clear( )

# Deleting all elements

B) append adds its argument as a single element to the end of a list. The length of the list itself will increase by one. extend iterates over its argument adding each element to the list, extending the list.

c) In python, the dictionary functions pop() and popitem() are used to remove items from a dictionary. In this tutorial we’ll look at these functions, their syntax and use-cases along with some examples.

Before we proceed, here’s a quick refresher on dictionaries in python – Dictionaries are a collection of items used for storing key to value mappings. They are mutable and hence we can update the dictionary by adding new key-value pairs, removing existing key-value pairs, or changing the value corresponding to a key. For more, check out our guide on dictionaries and other data structures in python

d) The MIN and MAX functions are just what the names imply. MIN will find the lowest number in a range, while MAX finds the largest number in a range. One advantage to these functions is that they can be combined with the IF function. Combining functions means writing a formula that is a bit more complex, but is nevertheless handy in some worksheets. The MIN and MAX functions are just what the names imply. MIN will find the lowest number in a range, while MAX finds the largest number in a range. One advantage to these functions is that they can be combined with the IF function. Combining functions means writing a formula that is a bit more complex, but is nevertheless handy in some worksheets. And, we will also look at examples where the MIN and MAX functions are used in combination with the IF function.

Similar questions