Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Create a
Once they are finished entering these values, use a dictionary comprehension to create a new dictionary featuring only the cities whose populations are over 2 million.
Print the key/value pairs in the resulting dictionary out.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- &5.Shiulsarrow_forwardyou have the following dictionary. Just copy the dictionary from the question to your editor sitcom={ 'friends': ['joey', 'rachel'], 'BBT': ['sheldon', 'leonard'], 'brooklyn 99': ['amy', 'rosa']} Write a python function that will take the dictionary as a parameter and also an integer that will be given by the user. Then you have to find out which key’s corresponding values have the length same as the user input. Then print the following. NB: Your code needs to be worked if the given dictionary is changed. (You can not use the len(), count() functions) Sample Input 1: 14 function call 1: sitcom_calc(sitcom,value) Sample Output 1: sheldon leonard are the bestest friends ever Explanation: Here, the user input is 14. When the key is ‘friends’, the length of its corresponding values are 4 (joey)+ 6 (rachel) =10. So, they don't match. Now, when the key is ‘BBT’ the length of its corresponding values are 7 (sheldon)+ 7 (leonard) =14. So, match! That’s why, sheldon leonard…arrow_forwardUsing the Dictionary below, create a game that picks a random number based on the length of the dictonary. Using that random number, prompts the user for the capital of that state (the key for your dictionary) - Use the code snipet below Your program must prompt the user by asking "What is the capital of XXX:" and XXX is the state name. Your program should compare the guess to the actual capital for that state. If the guess is correct, increment the number of correct guesses. If the guess is wrong, increment the numner of incorrect guesses. When the user types in quit in eithe uppercase or lowercase, the program should print out the results of the game by telling the payer you had XX correct responses and YY incorrect responses. Then the program should end. Make sure to do the Outline and Logic parts for your program. You can include your Python code in yout Word document, or submit it as a Python (;py) file Upload your work to this assignment when completed. # Pick…arrow_forward
- Write a function named count_vowels that accepts a string as an argument. The function should count the number of times each vowel (the letters a, e, i, o, and u) appears in the string, and store those counts in a dictionary. When the function ends, the dictionary should have exactly 5 elements. In each element, the key will be a vowel (lowercase) and the value will be the number of times the vowel appears in the string.arrow_forward13. While dictionaries are designed so that we can find a value based on a key, every so often we need to perform a reverse lookup. For example, imagine a dictionary where the keys are names and the values are phone numbers. Usually we want to find the phone number based on the name, but occasionally you might need to find a name based on the phone number. Write a function called reverse_lookup(dictionary, value) that returns all the keys in the dictionary associated with the specified value. Note: In dictionaries, the keys are guaranteed to be unique, but the values are not. So your function should return a list containing all of the matching keys (if any) Example: Given this dictionary, groups = {'Apple': 'Fruit', 'Spinach': 'Vegetable', 'Banana': 'Fruit'} reverse_lookup (groups. Vegetable') ["Spinach'] reverse_lookup (groups, Fruit') ['Apple'. 'Banana'] reverse_lookup (groups. 'Meat') []arrow_forwardWrite a program that creates a dictionary containing Canadian provinces' abbreviations as the keys (e.g., 'on') and their long format as the values (e.g., 'Ontario'). Use the internet to get a list of provinces and their abbreviations. The program should then randomly quiz the user by displaying the abbreviation of the province and asking the user to enter the extended format for the abbreviation. The program should keep count of the number of correct and incorrect responses.arrow_forward
- This section has been set as optional by your instructor. OBJECTIVE: Write a program in Python that prints the middle value of a dictionary's values, using test_dict from the test_data.py module. NOTE: test_dict is created & imported from the module test_data.py into main.py Example 1: test dict = {'a':1,'b':9,'c':2,'d':5} prints 5 Example 2: test_dict = {'b':9,'d':5} prints 5 Hint: You may(or may not) find the following function useful: list.sort() which sorts the elements in a list. Note: the result is automatically stored in the original list, and return value from the function is None Туре list = [1, 2,3,2,1] After calling: list = [1,1,2,2,3] list.sort(), 339336.2266020 x3zgy7 LAB 13.11.1: Middlest Value (Structured Types) АCTIVITY 0/11 File is marked as read only Current file: test_data.py 1 #This module creates the test_dict to be used in main.py 2 #Reads input values from the user & places them into test_dict 3 dict_size = int(input()) #Stores the desired size of test_dict. 4…arrow_forwardgiven dictionaries, d1 and d2, create a new dictionary with the following property. For each entry(a,b) in d1, if a is not a key of d2 then add (a,b) to the new dictionary. For each entry (a,b) in d2, if a is not a key of d1 then add (a,b) to the new dictionary. For example, if d1 is {2:3, 8:19, 6:4, 5:12} and d2 is {2:5, 4:3, 3:9}, then the new dictionary should be {8:19, 6,4, 5:12, 4:3, 3:9}. using puthonarrow_forwardNeed help answering this python question Create a dictionary of your friends that you found in 2017 and 2018. So, the keys are '2017' and '2018. For example: friend_solar = {2022: ["James", "Linda"] , 2023: ["Joshua", "Zoey"]} Print the friend's name Ask the user to enter a name of their friends. Then show the friend you found in 2022 or 2023. Ask the user to add a new friend name to the 2022 or 2023 lists (You need also to ask the user what year they want to add the friend name). Then add the entered friend name to the dictionary(2022 or 2023 value) Print the friends' dictionary on the screen.arrow_forward
- pleasensolve below "&1".arrow_forwardCreate a program that accepts a user-specified number of students and their corresponding grades on a test. Store the names and grades in a dictionary. Once the user has entered the information, they should be able to type in a student's name and that student's individual test score should be output to the screenarrow_forwardPYTHON QUESTION This assignment requires you to create a dictionary by reading the text file created for the Chapter 6 assignment. The dictionary should have player names for the keys. The value for each key must be a two-element list holding the player's goals and assists, respectively. See page 472! Start with an empty dictionary. Then, use a loop to cycle through the text file and add key-value pairs to the dictionary. Close the text file and process the dictionary to print the stats and determine the top scorer as before. In fact, much of the code used in program6_2.py can be copied and used for this program. Printing the stats for each player is the most challenging part of this program. To master this, refer to the examples in the zip file that can be downloaded from the "Dictionary values can be lists" link in the "Learn Here" part of this module. NOTE: you do not need to submit the text file. Submit just this program. The required output should be the same well-formatted table…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education