Copy of Problem Set 4

.docx

School

University of Alabama, Birmingham *

*We aren’t endorsed by this school

Course

MISC

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

8

Uploaded by UltraPartridge3798

Problem Set 4 Important - Before you begin: Please remember to adhere to all requirements outlined in the General Instructions for Problem Sets document. Need Help? - If you need help with an assignment, don't hesitate to ask! This course features an InScribe Learning Community that provides a variety of assistance options. Remember, it's okay to ask for help when you need it. We're here to support your learning journey. Good luck, and happy coding! Problem 1: Basic Data Structures Points Possible: 10 This problem will allow you to demonstrate your understanding of lists, sets, tuples, and dictionaries. Instructions: 1. For this problem, follow these steps: a. Create a list named dogs containing the following elements: “Bulldog”, “Poodle”, “Beagle”, and “Terrier”. b. Print the list. c. Convert the dogs list to a tuple named dogs _tuple . d. Print the tuple. e. Convert the dogs list to a set named dogs _set . f. Print the set. g. Convert the dogs list to a dictionary named dogs _dict that contains the dogs as keys and their lengths as values: IFT 101 - Rev. Spring 2024
i. Lengths being the size of the word (key) - Bulldog is 7, Poodle is 6, but these should not be hardcoded values, you need to use the len() function to gather the length of the key. h. Print the dictionary. i. Add “Pug” and “Chihuahua” to the dogs list. j. Remove “Beagle” from the dogs list. k. Print the updated list. l. Update dogs_dict to reflect the changes made to the dogs list. m. Print the updated dictionary. 2. When your program runs, it should match the expected output below. 3. Submission: Save your program’s source code using the following naming convention: PS4_P1_<Your First Name>_<Your Last Name>.py Submit the file as per the instructions under the 'Submission' section in the General Instructions for Problem Sets document. You will submit this file and all other problem set solution files at the same time. Problem 2: Count Odd and Even Using Loops Points Possible: 20 This problem will provide you with an opportunity to demonstrate your understanding of loops, lists, and string methods. Instructions: IFT 101 - Rev. Spring 2024
1. Write a program that allows the user to input as many integers as they would like, separated by commas. The program then counts the number of even numbers using a while loop. To verify that this count is correct, the program also counts the number of odd numbers using a for loop. You will need to perform the following steps. a. Ask the user to enter integers separated by commas. b. Convert the input to a list of integers. c. Print the total count of numbers entered. d. Use a while loop to go through the list and count the even numbers. e. Use a for loop to go through the list and count the odd numbers. f. Print the counts to the shell. 2. When your program runs, it should match the expected output below but should work for any user input that consists of integers separated by commas. 3. Submission: Save your program’s source code using the following naming convention: PS4_P2_<Your First Name>_<Your Last Name>.py Submit the file as per the instructions under the 'Submission' section in the General Instructions for Problem Sets document. You will submit this file and all other problem set solution files at the same time. Problem 3: Network Device Inventory Points Possible: 30 This problem will provide you with an opportunity to demonstrate your understanding of the properties and practical applications of lists, tuples, sets, and dictionaries. IFT 101 - Rev. Spring 2024
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