
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
Concept explainers
Question
![To type hello in your phone, you would have pressed the keys in the following order: 44-33-555-555-
666. To denote the pauses you have to take between entering each series of numbers, we will be using
space characters. So, the string '44 33 555 555 666' would be translated into 'hello'. To represent
the mapping between a sequence of digits and the letter that it represents we will be using a dictionary.
The dictionary will be mapping integers between 0 and 9 to lists of strings. The position of the string
in the letter denotes how many times the integer should be repeated for it to represent such string. So,
for instance the dictionary {2 : ['a', 'b', 'c'], 7 : ['p', 'q', 'r', 's']} tells us that to represent
the string 'a' we need the integer 2 repeated once (because 'a' is the first string in the list to which the
key 2 maps). On the other hand, to represent the string 'r' we need to use the integer 7 repeated three
times, since 'r' is the third string in the list to which 7 maps.
Write a function (including docstring) called same_chars that takes a string as input and returns true if
the string contains at least one character and all the characters within the strings are equal.
For example:
> same_chars('555')
True
>>> same_chars('aaaaa')
True
>>> same_chars('COMP')
False
>>> same_chars('aaAa')
False](https://content.bartleby.com/qna-images/question/4f00f67d-abe4-4062-b2e6-94501e662452/bf811668-19c7-4297-be99-e0b0a2d86cc2/sasp5lq_thumbnail.jpeg)
Transcribed Image Text:To type hello in your phone, you would have pressed the keys in the following order: 44-33-555-555-
666. To denote the pauses you have to take between entering each series of numbers, we will be using
space characters. So, the string '44 33 555 555 666' would be translated into 'hello'. To represent
the mapping between a sequence of digits and the letter that it represents we will be using a dictionary.
The dictionary will be mapping integers between 0 and 9 to lists of strings. The position of the string
in the letter denotes how many times the integer should be repeated for it to represent such string. So,
for instance the dictionary {2 : ['a', 'b', 'c'], 7 : ['p', 'q', 'r', 's']} tells us that to represent
the string 'a' we need the integer 2 repeated once (because 'a' is the first string in the list to which the
key 2 maps). On the other hand, to represent the string 'r' we need to use the integer 7 repeated three
times, since 'r' is the third string in the list to which 7 maps.
Write a function (including docstring) called same_chars that takes a string as input and returns true if
the string contains at least one character and all the characters within the strings are equal.
For example:
> same_chars('555')
True
>>> same_chars('aaaaa')
True
>>> same_chars('COMP')
False
>>> same_chars('aaAa')
False
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 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
- Please complete on Python Write a program that keeps a dictionary in which both keys and values are strings, names of students and their courses grades. Prompt the user of the program to add or remove students, to modify grades, or to print all grades. The printout should be sorted by name and formatted like this: <br>Carl: B+ <br>Joe: C <br>Sarah: A <br>Francine: Aarrow_forwardThis 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_forwardAs part of this assignment, the program that you will be writing will store current grades in a dictionary using course codes as keys and with values consisting of percent grades in lists. The main functions of this program are to print a student's gradebook, to drop the lowest grade in each course, print the student's gradebook again, drop the course with lowest average, and finally printing the student's gradebook again. This program requires a main function and a custom value-returning function. In the main function, code these basic steps in this sequence (intermediate steps may be missing): start with an empty dictionary that represents a gradebook and then use a while loop to allow the input of course codes from the keyboard. End the while loop when the user presses enter without entering data.within the while loop:for each course entered, use a list comprehension to generate five random integers in the range of 70 through 100. These random integers in a list represent the…arrow_forward
- Please answer the ques in python with showing the answers. Q: A car dictionary: a) Implement a dictionary car with the keys brand, model, and color. Give appropriate values for each key (you choose). b) Print each item in the dictionary (see example output) c) Add a key transmission to the dictionary with the value ‘automatic’. d) Print the value for the key transmission (use the get method). Output Example: subaru crosstrek sapphire blue automaticarrow_forwardI am struggling with this program question for the last few hours. Could you please assist? Write a program that prompts user to enter make, model, color and year of their car. Store the input data in a dictionary and a list. The dictionary has "make", "model", "color", and "year" as keys. The dictionary values are user inputted data. In addition, store the input data in a list also. Store the make, model, color and year of the car in a list. Display the dictionary and list. Here are sample program run. Your program output message should be similar to below. Make sure use other inputs to verify the correctness of the program. What is the make of your car? Ford What is the model of your car? Taurus What is color of your car? white What is the year of your car? 1997 Car info dictionary: {'make': 'Ford', 'model': 'Taurus', 'color': 'white', 'year': 1997} Car info list: ['Ford', 'Taurus', 'white', 1997] (I am getting syntax errors all over the place) I do have tutoring sessions but I'm in…arrow_forwardThis code is full of errors, what are 4 of them and how I would fix them?arrow_forward
- In python: student_dict is a dictionary with students' name and pedometer reading pairs. A new student is read from input and added into student_dict. For each student in student_dict, output the student's name, followed by "'s pedometer reading: ", and the student's pedometer reading. Then, assign average_value with the average of all the pedometer readings in student_dict..arrow_forwardDictionary vegetables_info contains key-value pairs that represent the grade received by each vegetable item in an inspection. Dictionary grade_scale contains key-value pairs that represent the meaning of each grade. String vegetables_name is read from input. Complete the following tasks: Use pop() to remove vegetables_name from vegetables_info and assign vegetables_num with the value returned. Any string that is not a key in vegetables_info has the default value 0. Assign patient_grade with the value associated with key vegetables_num in grade_scale. Any number that is not a key in grade_scale has default value 'not reported'.arrow_forwardOverview This is a review assignment where you will use multiple tools you have picked up so far throughout the course. If you're confused about how to do something make sure you look back at earlier assignments. In this program you will start by declaring an empty dictionary named population_dict. Then you will use a while-loop to prompt a user for a series of cities and their populations, storing the input in population_dict). After this you will prompt the user to decide what is the maximum population for a city to be considers a small down. Finally, you will open a file called populationdata.txt where you will write the results. Expected Output Example of standard out (the console): What is next city? (enter q to quit) Long Beach What is the population of Long Beach? 362000 What is next city? (enter q to quit) Los Angeles What is the population of Los Angeles? 382000000 What is next city? (enter q to quit) San Diego What is the population of San Diego? 136000000 What is next city?…arrow_forward
arrow_back_ios
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