CS 1101 – Programming Fundamentals

Description

Introduction

Don't use plagiarized sources. Get Your Custom Assignment on
CS 1101 – Programming Fundamentals
From as Little as $13/Page

Welcome to unit 7!

Unit 7 provides comprehensive coverage of Python’s two powerful data structures, the dictionary, and the tuple. You will learn how to use each of these types, along with how to use them together.

Dictionaries (which are implemented as objects) provide a simple way to store data and retrieve it using an index key. Dictionaries are based on key-value pairs. The key identifies the data and can be used to store, retrieve, and update the data. It must be immutable. The value part of the pair is the actual data, which can be any type, including a list or even another dictionary. An example use of a dictionary might be to store the number of days in a month and retrieve it using the name of the month. For January, the key would be “January,” and the value would be 31.

Tuples are sequences of values, like lists. Unlike lists and dictionaries, tuples are immutable. Thus tuples can be keys in a dictionary. Tuples are useful for assigning multiple values, iterating through multiple lists at once, and iterating through the key-value pairs in a dictionary.

Reading Assignment

Reading Assignments are designed to expand your knowledge of the topics introduced in the Overview and provide the knowledge you will need to successfully complete the assignments in this unit. As you read through the learning resource and watch the videos consider the following:

What are the differences between dictionaries, tuples, and lists?
What is meant by immutable?
How can lists be converted to tuples?
READ
Think Python: How to think like a computer scientist
Chapter 11 – Dictionaries
Chapter 12 – Tuples
WATCH: PYTHON BEGINNER TUTORIAL 8 – FOR LOOP, LISTS, AND DICTIONARIES

WATCH: PYTHON TUPLES | PYTHON TUPLES TUTORIAL | PYTHON TUTORIAL | PYTHON PROGRAMMING | SIMPLILEARN

SUPPLEMENTAL READING
Think Python: How to think like a computer scientist
Chapter 13 – Case study: Data structure selection
REFERENCES
Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tea Press. https://greenteapress.com/thinkpython2/thinkpython2.pdf
kjdElectronics. (2017, August 5). Python beginner tutorial 8 – For loop, lists, and dictionaries [Video]. YouTube. https://youtu.be/bE6mSBNp4YU
Simplilearn. (2019, January 25). Python tuples | Python tuples tutorial | Python tutorial | Python programming | Simplilearn [Video]. YouTube. https://youtu.be/wRC4H-k57eg
Discussion Assignment

Welcome to the Unit 7 Discussion Forum!

Implement your own Python code examples to describe how tuples can be useful with loops over lists and dictionaries. Do not copy code from the textbook or any other source.

Your descriptions and examples should include: the zip function, the enumerate function, and the items method.

The code and its output must be explained technically whenever asked. The explanation can be provided before or after the code, or in the form of code comments within the code. For any descriptive type question, Your answer must be at least 150 words.

End your discussion post with one question related to programming fundamentals learned in this unit from which your colleagues can formulate a response or generate further discussion. Remember to post your initial response as early as possible, preferably by Sunday evening, to allow time for you and your classmates to have a discussion.

When you use information from a learning resource, such as a textbook, be sure to credit your source and include the URL. Continue to practice using APA format for citations and references.

Programming Assignment
ASSIGNMENT INSTRUCTIONS:

This assignment assesses your skills and knowledge on constructing code to manipulate the content of a dictionary.

In this unit, we have explored the fundamental concepts of Iterations and Strings in Python. Before you proceed with this assignment, please review the reading material listed below:

Think Python: How to think like a computer scientist : Chapter 11 – Dictionaries
Python Beginner Tutorial 8 – For loop, Lists, and Dictionaries

Please ensure that you review all examples presented in the Chapter before you work on this assignment.

In a program, a dictionary contains lists of students and their courses. The teacher is interested to have a dictionary that has the courses as key and the students enrolled in each course as values. Each key has three different values.

To address this requirement, write a function to invert the dictionary and implement a solution that satisfies the teacher’s need. In particular, the function will need to turn each of the list items into separate keys in the inverted dictionary. Also provide a technical explanation for the code and its output in minimum 200 words.

Sample input:

{

‘Stud1: [‘CS1101’, ‘CS2402’, ‘CS2001’],

‘Stud2: [‘CS2402’,’CS2001’,’CS1102’]

}

Inverted Output:

{

‘CS1101’: [‘Stud1’],

‘CS2402’:[‘Stud1’,’Stud2’],

‘CS2001’: [‘Stud1’,’Stud2’]

‘CS 1102’[‘Stud2’]

}

PROGRAMMING INSTRUCTIONS:
Print the original dictionary as well as the inverted dictionary.
Include your the Python program and the output in your submission.
The code and its output must be explained technically. The explanation can be provided before or after the code, or in the form of comments within the code.
SUBMISSION INSTRUCTIONS:
Submit the solution in a word document.
Make sure your submission is double-spaced, using Times New Roman, 12-point font, with 1” margins.
Use sources to support your arguments. Add a reference list at the end of the submission. For assistance with APA formatting, view the Learning Resource Center: Academic Writing.
Your submission should be clearly written, concise, and well organized, and free of spelling and grammar errors. Read the grading rubric to understand on how your work will be evaluated.
REFERENCES:
Downey, A. (2015). Think Python: How to think like a computer scientist (2nd ed.). Green Tea Press.
kjdElectronics. (2017, August 5). Python beginner tutorial 8 – For loop, lists, and dictionaries [Video]. YouTube. https://youtu.be/bE6mSBNp4YU
Raj, A. (2022, March 3). Reverse a dictionary in Python. PythonForBeginners.
Python Dictionaries. (n.d.). W3schools.

This assignment will be assessed by your instructor using the rubric available on the assignment page located on the course homepage.