Assignment04 (1)

.docx

School

Texas A&M University, Commerce *

*We aren’t endorsed by this school

Course

450

Subject

Computer Science

Date

May 13, 2024

Type

docx

Pages

2

Uploaded by GrandSteel14470 on coursehero.com

CSCI 333 Assignment 04 Data structures (List, tuple, set, and dict) 50 points 1. (15 points) Given the list values = [] , write code that fills the list with each set of numbers below. Note: use loops if it is necessary a) 1 2 3 4 5 6 7 8 9 10 b) 0 2 4 6 8 10 12 14 16 18 20 c) 1 4 9 16 25 36 49 64 81 100 d) 0 0 0 0 0 0 0 0 0 0 e) 1 4 9 16 9 7 4 9 11 f) 0 1 0 1 0 1 0 1 0 1 g) 0 1 2 3 4 0 1 2 3 4 # python code 2. (5 points) Write a function that takes a tuple as an argument and returns the tuple sorted. # python code 3. (5 points) Write a statement that creates a dictionary containing the following key-value pairs: 'a' : 1 'b' : 2 'c' : 3 # python code 4. (5 points) What will the following code display? dct = {'Monday':1, 'Tuesday':2, 'Wednesday':3} print(dct.get('Monday', 'Not found')) # result
5. (5 points) After the following code executes, what elements will be members of set3, ? set1 = set([10, 20, 30, 40]) set2 = set([40, 50, 60]) set3 = set1.union(set2) set4 = set1.intersection(set2) set5= set1.difference(set2) # result 6. (15 points) Given a dictionary gradeCounts = { "A": 8, "D": 3, "B": 15, "F": 2, "C": 6 } write the Python statement(s) to print: a) all the keys. b) all the values. c) all the key and value pairs. d) all of the key and value pairs in key order. e) the average value. f) a chart similar to the following in which each row contains a key followed by a number of asterisks equal to the key’s data value. The rows should be printed in key order, as shown below. A: ******** B: *************** C: ****** D: *** F: ** (10 points) Python program # python source code (3 points) Screenshot of the output # python source code (2 points) Save the python program and submit it to D2L
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help