Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

21. (+20) Write a python program that: Ask the user for a string and creates the following dictionary: The values are the letters in the

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

21. (+20) Write a python program that: Ask the user for a string and creates the following dictionary: The values are the letters in the string, with the corresponding key being the place in the string. For example if the user entered the string "CSC120" then create the dictionary d a. b. Display the length of the dictionary d In this case it is 6 Ask the user for a key(integer). If the key is in the dictionary display the corresponding value. As an example if the user entered 2 display 'C, if the user entered a key that was not in the dictionary display "Error key not found" Ask the user for a value (one of the characters). If the value is in the dictionary display Value found" otherwise display "Value not found". As an example if the user entered?display "value found" Ask the user for a string of digits, separated by a comma. Print out the corresponding values for those digits. For example if the user enters the string "0,1, 4" then print out 'C 'S' '2' (or "CS2") At issue is how to handle out of range digits for example, in our case, any digits in the range 0...5 should generate a corresponding value but any digit(s)> 5 OR

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions