Question: Dictionary num _ to _ word contains key - value pairs 9 . 0 : 'nine point zero', 8 . 5 : 'eight point five',

Dictionary num_to_word contains key-value pairs 9.0: 'nine point zero', 8.5: 'eight point five', 7.5: 'seven point five', and 5.5: 'five point five'. In the try block, float num_key is read from input. The key-value pair with num_key as the key is deleted from num_to_word. Complete the following tasks:
Write an exception handler to catch ValueError and output 'float(): A float is expected.'
Write an exception handler to catch KeyError and output 'num_key cannot be deleted from num_to_word.'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!