Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question #1 Write the code for a Python function called loadDictionary that accepts a dictionary, a list, and a letter (with a default value of

Question #1 Write the code for a Python function called loadDictionary that accepts a dictionary, a list, and a letter (with a default value of 'X') and stores the list in the dictionary using the letter as the key before returning the entire dictionary. The function prototype MUST be: def loadDictionary(book, sequence, key = 'X') : For example, given the following variables: letter = 'Q' myDict = { } seq1 = [31, 32, 33, 34, 35, 36, 37, 38, 39] then the function call and print: newDict = loadDictionary(myDict, seq1, letter) print(newDict) would display: {'Q': [31, 32, 33, 34, 35, 36, 37, 38, 39]} 

import math import random import string import collections import datetime import re import time import copy from functools import reduce # YOUR CODE BELOW...  def loadDictionary(myDict, seq1, letter='X') : # your code here... # end def def dotProduct(myDictParam) : # your code here... # end def def integerToRoman(n) : # your code here... # end def  def main( ) : letters = ['M', 'X', 'Y', 'Z'] myDict = { } seq1 = [31, 32, 33, 34, 35, 36, 37, 38, 39] seq2 = [5, -3, 8, 17, 1, 9, -4, -2, 7] seq3 = [6, -5, 12, -3, 25, 18, -7, 21, 88] seq4 = [8, 2, 29, 8, 10, 4, 91, 76, 15] newDict = loadDictionary(myDict, seq1, letters[0]) # key of 'M' newDict = loadDictionary(newDict, seq2) # key will use default value of 'X' result = dotProduct(newDict) print(newDict) print("dotProduct with seq1 and seq2: ", result) newDict = loadDictionary(newDict, seq3, letters[2]) # key of 'Y' result = dotProduct(newDict) print(newDict) print("dotProduct with seq1, seq2, and seq3: ", result) newDict = loadDictionary(newDict, seq4, letters[3]) # key of 'X' result = dotProduct(newDict) print(newDict) print("dotProduct with seq1, seq2, seq3, and seq4: ", result) print("keys in final dictionary: ", newDict.keys( )) for i in range(51) : print(integerToRoman(i)) romansList = [ 499, 500, 504, 508, 509, -6, 600, 777, 800, 850, 860, 870, 880, 890, 900, 1000, 1004, 1008, 1009, 1222, -1222, 1400, 1404, 1409, 1889, 1900, 1909, 1929, 1969, 5000, 3450, 3979, 3999, 4000, 4001, 88 ] for i in romansList : print(integerToRoman(i)) # end main( ) if __name__ == "__main__" : main( )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions