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
Program - Python Problem below the code
This is my code for a dictionary of student's test scores.
def main():
#Create a dictionary with name as key
#Marks as the list of values
student_dictionary=\
{
'Brian': [94, 89, 92],
'Rachel': [100,90,65],
'Jon': [67.5,95,100],
'Brit': [0,78,80] ,
'Gret': [65,100,78],
'Andrea': [55.5,67,79]
}
#Loop that print name and list of marks
for key, values in student_dictionary.items():
print('Name: ', key, " , Marks:", values)
#Call main function
if __name__ == '__main__':
main()
Problem:
print the dictionary data using a loop that starts with
for key in
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 4 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
- Python code please help, indentation would be greatly appreciatedarrow_forwardCode the following directions in python. 1.Assume the variable dct references a dictionary. Write an if statement that determines whether the key 'Jim' exists in the dictionary. If so, delete 'Jim' and its associated value. 2.Write code to create a set with the following integers as members: 10, 20, 30, and 40. 3.Assume each of the variables set1 and set2 references a set. Write code that creates another set containing all the elements of set1 and set2, and assigns the resulting set to the variable set3.arrow_forwardWrite 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_forward
- My code from milestone 1 # Define the quiz_type dictionary quiz_type = { 1: "BabyAnimals", 2: "Brooklyn99", 3: "Disney", 4: "Hogwarts", 5: "MyersBriggs", 6: "SesameStreet", 7: "StarWars", 8: "Vegetables" } # Print the welcome message print("Welcome to the Personality Quiz!") print() print("What type of Personality Quiz do you want to run?") print() for number, quiz_name in quiz_type.items(): print(f"{number} - {quiz_name}") print() test_number = int(input("Choose test number (1-8): ")) # Check if the test_number is valid if test_number in quiz_type: quiz_name = quiz_type[test_number] print() print(f"Great! Let's begin the {quiz_name} Personality Quiz...") else: print("Invalid test number. Please choose a number between 1 and 8.") ------------------------------------------------------------------- Milestone #3 code : # Ending statements with the period to easily split them as mentioned in the question. questions = [ "I…arrow_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_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
- Assume the variable definitions references a dictionary. Write an if statement that determines whether the key 'marsupial' exists in the dictionary. If so, delete 'marsupial' and its associated value. If the key is not in the dictionary, display a message indicating so.arrow_forwarddef my_index_1(my_list:List[int], my_element:int)->int:"""Our version of the one-argument version of the index function.https://docs.python.org/dev/library/stdtypes.html#common-sequence-operations)This function takes a list and an element, and returns the smallestindex where the element occurs in the list. This function returnsNone if the element is not in the list.Arguments:my_list (list): A list of integers.my_element (int): The element to be found.Returns:int: The smallest index at which my_element is found in my_list.Examples:>>> print(my_index_1([], 2))None>>> print(my_index_1([1, 2, 3], 2))1>>> print(my_index_1([3, 1, 2, 3, 1], 2))2>>> print(my_index_1([3, 1, 2, 3, 1], 3))0""" Please solve this in Pythonarrow_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
- Assume the following list exists: names = ['Chris', 'Katie', 'Joanne', 'Kurt'] Write a statement that uses a dictionary comprehension to create a dictionary named X in which each element contains the length of a name from the list as the key, and the corresponding name's initial character as its value.arrow_forwardPython question please include all steps and screenshot of code. Also please provide a docstring, and comments throughout the code, and test the given examples below. Thanks. Write function week() that takes no arguments. It will repeatedly ask the user to enter anabbreviation for a day of the week (Mo, Tu, We, Th, Fr, Sa, or Su) and then print thecorresponding day. Use a dictionary to implement this result.>>> week() Enter day abbreviation: TuTuesdayEnter day abbreviation: SuSundayEnter day abbreviation: SaSaturdayEnter day abbreviationarrow_forwardProgram - Python (problem under code) This is my code for a dictionary of student's test scores. def main():#Create a dictionary with name as key#Marks as the list of valuesstudent_dictionary=\{'Brian': [94, 89, 92],'Rachel': [100,90,65],'Jon': [67.5,95,100],'Brit': [0,78,80] ,'Gret': [65,100,78],'Andrea': [55.5,67,79]}#Loop that print name and list of marksfor key, values in student_dictionary.items():print('Name: ', key, " , Marks:", values)#Call main functionif __name__ == '__main__':main() Problem: Find and print out Rachels second score (should be a 90)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