Question
1. Define a function create_colors_dict that takes a parameter favorite_colors as a list of tuples in the format (name, color) and r eturns a dictionary
1. Define a function create_colors_dict that takes a parameter favorite_colors as a list of tuples in the format (name, color) and returns a dictionary consisting of a color as key and the value is a list of names with that favorite color.
2. Consider a traffic light that turns from green to yellow to red and then to green again.
Define a function next_color that takes a parameter current_color as one of the strings 'red', 'yellow', 'green' and returns a string representing the next color of the traffic light.
3. In at most 80 characters on one line, answer the following question -
Write a Python expression using a list comprehension that filters a list of numbers, named my_numbers, returning a list of numbers that are at least the value 70.
4. In at most 80 characters on one line, answer the following question - Given a set, named my_set, write a Python expression that returns a list of the elements in the set in descending order.
5. In at most 80 characters on one line, answer the following question - Given a list, named my_list, which is sorted in ascending order, write a Python expression representing a tuple consisting of the minimum and maximum values in the list.
6. In at most 80 characters on one line, answer the following question - Assume that the variable my_input is bound to a string representing an employee's salary without decimals. Write a Python expression that binds the variable salary to a numeric representation of the employee's salary.
7. In at most 80 characters on one line, answer the following question - Write a Python expression to determine whether the isbn 9781234567890 is a key in the bookisbn dictionary.
8. In at most 80 characters on one line, answer the following question - Consider a populated dictionary, named bookisbn, that maintains an association of unique isbn book codes of 13 characters to the book's title and author, represented as a tuple. Write a Python expression to add the association of the isbn 9781119498537 for 'Python for Everyone' by 'C. Horstmann' to that dictionary.
9. In at most 80 characters on one line, answer the following question - Write a Python expression that unpacks a variable credit_card_info containing a tuple with the credit card number, expiration date, and CCV number. When unpacking use the following variable names: credit_card, expires, ccv.
10. In at most 80 characters on one line, answer the following question - Write a Python expression using slicing that returns the 5-digit zip code as a string from a variable named zipplus4, which consists of the 5-digit zip code followed by a dash followed by the additional 4 digits, e.g., #####-####.
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