Question
4.4 Stay under 80 characters on all code and comment lines Ask for input() with descriptive prompts telling users what is expected o Especially remember
4.4 Stay under 80 characters on all code and comment lines Ask for input() with descriptive prompts telling users what is expected o Especially remember to tell user what delimiter youre expecting when using split() Make sure to validate user input for data type, value range and other problem requirements Print output that clearly explains what is being printed (where necessary) o In other words, dont just print a 5 unless its clear what that 5 represents. Import statements should be immediately after the program docstring Make sure to include # line comments (just a few in each program, dont go crazy) Use snake_case (lower case plus underscores) for variables CONSTANT variables must be all upper case and immediately following any import statements Do NOT create user defined functions for this assignment. Only base python functions and methods can be used, along with those in the modules listed below. Modules Allowed You may only import the following modules into your programs and use their methods and attributes, unless first receiving special (and unlikely) permission from your facilitator: math operator os re string sys THE question is
4.4: Using MY_DICT = {a':15, 'c':18, 'b':20}, write a program to: a. calculate and print all the keys as a list. b. calculate and print all the values as formatted comma separated data (not as a list). c. print all the keys and values pairs as formatted data (not as a dictionary). d. sort in ascending order by key and print a list of tuples for all the keys and values pairs e. sort in ascending order by value and print as formatted data all the keys and values pairs Output must look as follows (obviously, without any data being hard-coded): a. Keys: ['a', 'c', 'b'] b. Values: 15, 18, 20 c. Key value pairs: a: 15, c: 18, b: 20 d. Key value pairs ordered by key: [('a', 15), ('b', 20), ('c', 18)] e. Key value pairs ordered by value: a: 15, c: 18, b: 20
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started