F01.justanswer.com



BE 1600Introduction to Programming and ComputationPythonAssignment 0636 pointsDue 03/10/2021 (11:45 A.M.)Assignment Objectives:To use Python dictionaries to store associative dataTo use Python tuples as a means of storing dataTo implement algorithms to compute elementary statisticsTo use methods from the Python statistics moduleTo learn how to produce a histogramSolution for this assignment will not be posted on Canvas; however, the solution of any of the assignment problems can be discussed in the class upon request of a student.All assignments must be submitted by the Canvas. No email or hard copy is accepted. You must follow the following format:For non-programming questions, use a word file to type your answers. Don’t use the text box on the Canvas to answer the questions or to write comments, we will not read it. State your answer clearly.For programming questions, include only the source file of each programming problem.Submit your files to the Canvas. You must submit your files on time; otherwise, you will receive zero.Use “Add Another File” feature on Canvas to upload each additional file; do not upload the files as a?compressed?folder.You can upload your files as many times as you like. Only the last attempt counts because the last files you uploaded are the only files your instructor will see.There will be several modules on the Canvas. You need to upload your files using the correct module on the Canvas.Name each file: Assignment (assignment number) for the word file [e.g. Assignment 02] and Assignment (assignment number) _ (Question number) for each programming question [e.g. Assignment 02_Q03]. To upload your file(s):In Course Navigation, click the ASSIGNMENTS module.Click the title of the assignment.Click the?Submit?Assignment button.Add?File. ...Add Another?File. ...Submit?Assignment. ...View?Submission.It is your responsibility to make sure that each file is uploaded correctly. If you uploaded a wrong file, you receive zero; files will not be accepted after due date even if you have a prove that the file is created before the due date. Make sure you review the Cheating & Plagiarism policy on Canvas.Use Python Shell Window to answer questions 1 and 2 on a word file. Use Python Script Window and write a program for Q.3. to Q.6. Submit 5 files (one word file and four .py files) to Canvas by the due date.(4 points) Answer the following questions:Write a statement that creates a dictionary containing the following key-value pairs:'a' : 1'b' : 2'c' : 3Write a statement that creates an empty dictionary.Assume the variable dct references a dictionary. Write an if statement that determines whether the key 'James' exists in the dictionary. If so, display the value that is associated with that key. If the key is not in the dictionary, display a message indicating so. 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. (9 points) Answer the following questions: What will the following code display?dct = {'Monday':1, 'Tuesday':2, 'Wednesday':3}print(dct['Tuesday']) What will the following code display?dct = {'Monday':1, 'Tuesday':2, 'Wednesday':3}print(dct.get('Monday', 'Not found'))What will the following code display?dct = {'Monday':1, 'Tuesday':2, 'Wednesday':3}print(dct.get('Friday', 'Not found')) What will the following code display?stuff = {'aaa' : 111, 'bbb' : 222, 'ccc' : 333}print(stuff['bbb']) How do you delete an element from a dictionary? How do you determine the number of elements that are stored in a dictionary? What will the following code display?dct = {1:[0, 1], 2:[2, 3], 3:[4, 5]}print(dct[3]) What values will the following code display? (Don’t worry about the order in which they will be displayed.)dct = {1:[0, 1], 2:[2, 3], 3:[4, 5]}for k in dct:print(k)Tuples resemble lists in many ways. However, as an immutable type, the ways in which they can be interacted with are limited. Take the following statements. What will happen if you try to add to the tuple in the manner shown? How can you rewrite the code to achieve the intended result?Tuple = ()for i in range (10):Tuple = Tuple + iProgramming Questions (When processing a string, a list or a dictionary, use loops)(5 points) If my dict = {'a':15 , 'c':35, 'b':10}, write Python code:to print all the keys.to print all the values.to print all the keys and values pairs.to print all the keys and values pairs in order of key.to print all the keys and values pairs in order of value.(6 points) Write a program that creates a dictionary containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following keyvalue pairs:The program should also create a dictionary containing course numbers and the names of the instructors that teach each course. The dictionary should have the following key-value pairs:The program should also create a dictionary containing course numbers and the meeting times of each course. The dictionary should have the following key-value pairs:The program should let the user enter a course number, and then it should display the course’s room number, instructor, and meeting time. (6 points) You can express a fraction as a tuple: (numerator, denominator).Write a function that adds two fractions that are passed as tuples.Write a function that multiplies two fractions that are passed as tuples.(6 points) Write a function that takes as input a string and prints a histogram of letter counts. A histogram can be done using stars characters. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download