Dictionary scores_dict contains four key-value pairs. Read a string from input, representing a key found in scores_dict. Then, assign the value associated with the key read with the current value times 2.
Added by Angel D.
Close
Step 1
Step 1: Read a string from input, representing a key found in scores_dict. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 54 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Solve this in Python. In this task, we will be finding a possible solution to number puzzles like 'SAVE' + 'MORE' = 'MONEY'. Each alphabet represents a digit. You are required to implement a function called addition_puzzle that returns a dictionary containing alphabet-digit mappings that satisfy the equation. Note that if there are multiple solutions, you can return any valid solution. If there is no solution, then your function should return False. >>> addition_puzzle('ANT', 'MAN', 'COOL') {'A': 8, 'C': 1, 'L': 9, 'M': 6, 'N': 7, 'O': 5, 'T': 2} >>> addition_puzzle('AB', 'CD', 'E') False Explanations: ANT + MAN = COOL: 872 + 687 = 1559 AB + CD = E: The sum of two 2-digit numbers must be at least a two-digit number. Your solution needs to satisfy 2 conditions: 1. The leftmost letter cannot be zero in any word. 2. There must be a one-to-one mapping between letters and digits. In other words, if you choose the digit 6 for the letter M, then all of the M's in the puzzle must be 6 and no other letter can be a 6. The addition_puzzle function takes in at least 3 arguments. The last argument is the sum of all the previous arguments. Note: The test cases are small enough, so don't worry too much about whether or not your code will run within the time limit.
Akash M.
The names and email addresses are originally stored in a file called phonebook.in, in the format: Harry Potter theboywholived@hogwarts.edu Hermione Granger brightestwitch@hogwarts.edu Ron Weasley roonilwazlib@hogwarts.edu Draco Malfoy myfatherwillhearaboutthis@hogwarts.edu Severus Snape halfbloodprince@hogwarts.edu Albus Dumbledore alasearwax@hogwarts.edu Your program should read from the file, storing the names and corresponding email addresses in a dictionary as key-value pairs. Then, the program should display a menu that lets the user enter the numbers 1 through 5, each corresponding to a different menu item: 1) look up an email address 2) add a new name and email address 3) change an email address 4) delete a name and email address 5) save address book and exit When the user enters 1, the program should prompt them for a name, and then print the corresponding email address. If there is no dictionary entry under that name, the program should print, "Sorry, no contact exists under that name." When the user enters 2, the program should prompt them for a name and an email address, then add a new key-value pair to the dictionary. When the user enters 3, the program should prompt them for a name and a new email address for that contact. It should change the value of the corresponding dictionary entry to match the new email address. When the user enters 4, the program should prompt them for a name and delete the corresponding dictionary entry. When the user enters 5, the program should write the names and email addresses in alphabetical order by first name to the file phonebook.out.
*** In python Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers and the ratings in a dictionary. Output the dictionary's elements with the jersey numbers in ascending order (i.e., output the roster from smallest to largest jersey number). Hint: Dictionary keys can be stored in a sorted list. Ex output: Enter player 1's jersey number: 84 Enter player 1's rating: 7 Enter player 2's jersey number: 23 Enter player 2's rating: 4 Enter player 3's jersey number: 4 Enter player 3's rating: 5 Enter player 4's jersey number: 30 Enter player 4's rating: 2 Enter player 5's jersey number: 66 Enter player 5's rating: 9 ROSTER Jersey number: 4, Rating: 5 Jersey number: 23, Rating: 4 Jersey number 30, Rating: 2
Shelayah R.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD