Make a program that modifies the list given below to display numbers from 1 to 8 in
descending order.
Input List is:
Final List required is:
list = [8,7,6,5,4,3,2,1]
>>> list.
>>> list.
>>> list.
>>> list.
pop()
remove(8)
append(8)
reverse()
insert(0,8)
sort()
Supported functions:
append(value), pop(), clear(), count(value), insert(index,value),
remove(value), reverse(), sort()
Syntax:
list.<function>
Enter command:
Make a program that converts the initial to the final dictionary and print all the fruit
names.
Input is:
{'apple': 'red','dog': 'animal',
'pear':
'green'}
Final Dictionary required is:
{'apple': 'red','pear': 'green',
'kiwi': 'brown'}
dictionary.
dictionary.
print(dictionary.
)
values()
update({'kiwi':'brown'})
keys()
popitem()
pop('dog')
add('kiwi','brown')
Supported functions:
update({key:value}),pop(key),popitem(),clear(),
Syntax:
dict.<function> or dict[key] = value
Enter command:
Make a program that modifies the set given below to make it a set of the first five
even
numbers.
Input Set is:
Final Set required is:
set = {2,4,6,8,10}
>>> set.
>>> set.
>>> set.
>>> set.
add(8)
add({10})
update({10})
remove(7)
intersection_update({9})
difference_update({9})
Supported functions:
add(value), pop(), remove(value), clear()
Syntax:
set.<function>
Enter command: