assignment 7.1 python data structures

Answered on: Friday 26 May , 2023 / Duration: 22 min read

Programming Language: Python , Popularity : 4/10

Python Programming on www.codeease.net

Solution 1:

Sure, I'd be happy to help you with that!

Python provides various built-in data structures that can be used to store and manipulate data in different ways. Some of the most commonly used data structures are lists, tuples, sets, and dictionaries. Here are some examples of how you can use each of these data structures in Python:

1. Lists: A list is a collection of items that are ordered and changeable. You can create a list in Python by enclosing a comma-separated sequence of items within square brackets. Here's an example:

You can access individual elements of a list using their indices, which start from 0. For example:

2. Tuples: A tuple is similar to a list, but it is immutable, which means that you cannot change its contents once it is created. You can create a tuple in Python by enclosing a comma-separated sequence of items within parentheses. Here's an example:

You can access individual elements of atuple using their indices, just like with a list. For example:

3. Sets: A set is an unordered collection of unique items. You can create a set in Python by enclosing a comma-separated sequence of items within curly braces. Here's an example:

Since sets are unordered, you cannot access their elements using indices. Instead, you can use loops or built-in methods to manipulate them.

4. Dictionaries: A dictionary is a collection of key-value pairs, where each key is associated with a value. You can create a dictionary in Python by enclosing a comma-separated sequence of key-value pairs within curly braces, with a colon separating each key and its value. Here's an example:

You can access individual values of a dictionary using their keys, like this:

I hope these examples help you understand how to use Python's built-in data structures! Let me know if youhave any more questions or if you need further clarification.

Solution 2:

Sure, here is the in-depth solution for assignment 7.1 Python data structures in Python with proper code examples and outputs:

**Assignment 7.1**

**Problem Statement**

Write a Python program that implements the following data structures:

**Solution**

**Explanation**

* A set is a collection of unique items.

**Additional Information**

* Sets are a useful data structure for storing unique items. They can be used to quickly find the presence or absence of an item in a collection.

Solution 3:

Sure, here's a descriptive answer for assignment 7.1 on Python data structures with proper code examples and outputs:

Python data structures are used to store and manipulate data in a program. There are several types of data structures available in Python, including lists, tuples, dictionaries, sets, and strings. Each data structure has its own unique features and uses.

Lists are ordered collections of items that can be of any data type. They are defined using square brackets \[\] and items are separated by commas. Here's an example of how to create a list:

This list contains five integers, 1 through 5\. We can access individual elements of the list using their index. For example, to access the first element of the list, we would use the index 0:

We can also modify elements in the list using their index. For example, to change the second element of the list to 10, we would use the following code:

Tuples are similar to lists, but they are immutable, meaning that once they are created, their elements cannot be changed. They are defined using parentheses () and items are separated by commas. Here's an example of how to create a tuple:

This tuple contains five integers, 1 through 5\. We can access individual elements of the tuple using their index. For example, to access the first element of the tuple, we would use the index 0:

We can also use tuples to return multiple values from a function:

Dictionaries are unordered collections of key-value pairs. They are defined using curly braces {} and keys are separated from values using a colon. Here's an example of how to create a dictionary:

This dictionary contains three key-value pairs. We can access individual elements of the dictionary using their key. For example, to access the value associated with the key 'name', we would use the following code:

We can also add new key-value pairs to the dictionary using the square bracket notation:

Sets are collections of unique items. They are defined using curly braces {} and items are separated by commas. Here's an example of how to create a set:

This set contains five integers, 1 through 5\. We can add new items to the set using the add() method:

Strings are sequences of characters. They are defined using single quotes ''. Here's an example of how to create a string:

We can access individual characters in the string using their index. For example, to access the first character of the string, we would use the index

More Articles :

Python beautifulsoup requests.

Answered on: Friday 26 May , 2023 / Duration: 5-10 min read

Programming Language : Python , Popularity : 9/10

pandas add days to date

Programming Language : Python , Popularity : 4/10

get index in foreach py

Programming Language : Python , Popularity : 10/10

pandas see all columns

Programming Language : Python , Popularity : 7/10

column to list pyspark

How to save python list to file.

Programming Language : Python , Popularity : 6/10

tqdm pandas apply in notebook

Name 'cross_val_score' is not defined, drop last row pandas, tkinter python may not be configured for tk.

Programming Language : Python , Popularity : 8/10

translate sentences in python

Python get file size in mb, how to talk to girls, typeerror: argument of type 'windowspath' is not iterable, django model naming convention, split string into array every n characters python, print pandas version, python randomly shuffle rows of pandas dataframe, display maximum columns pandas.

Search This Blog

Coursera python data structures assignment answers.

This course will introduce the core data structure of the Python programming ... And, the answer is only for hint . it is helpful for those student who haven't submit Assignment and who confused ... These five lines are the lines to do this particular assignment where we are ...

chapter 7 week 3 Assignment 7.1

python data structures chapter 7.1 assignment

Post a Comment

if you have any doubt , please write comment

Popular posts from this blog

Chapter 9 week 5 assignment 9.4.

Image

chapter 10 week 6 Assignment 10.2

Image

chapter 6 week 1 Assignment 6.5

Image

python data structures chapter 7.1 assignment

Python Data Structures

Week 1 - assignment 6.5.

Write code using find() and string slicing to extract the number at the end of the line below. Convert the extracted value to a floating point number and print it out.

text = "X-DSPAM-Confidence: 0.8475";

text = "X-DSPAM-Confidence: 0.8475"

Colpos = text.find(':') # Colon Position

text_a_Colpos = text[Colpos+1 : ] # Text after colon position

number = text_a_Colpos.strip()

print(float(number))

ans = float(text_a_Colpos)

# Using Split and join functions

num_str = text_a_Colpos.split() # string format of number in list

d = ""

num = d.join(num_str) # converts list into string

num_f = float(num)

print(num_f)

=============================================================================================

Week 3 - Assignment 7.1

Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file in upper case. Use the file words.txt to produce the output below.

when you are testing below enter words.txt as the file name.

file = input('Enter the file name: ')

fhandle = open(file)

for line in fhandle:

line_strip = line.strip()

line = line_strip.upper()

print(line)

Assignment 7.2

Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form:

X-DSPAM-Confidence: 0.8475

Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. Do not use the sum() function or a variable named sum in your solution.

when you are testing below enter mbox-short.txt as the file name.

fname = input('Enter the file name: ')

fhandle = open(fname)

for line in fhandle :

if 'X-DSPAM-Confidence:' in line :

Colpos = line.find(':')

num_string = line[Colpos + 1 : ]

num = float(num_string)

count = count + 1

Total = Total + num

avg = Total / count

print('Average spam confidence:',avg)

===============================================================================================

Week 4 - Assignment 8.4

Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and print the resulting words in alphabetical order.

fhandle = open('romeo.txt')

lst = list()

words = line.split()

print(words)

for word in words:

if lst is None:

lst.append(word)

elif word in lst:

Assignment 8.5

Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line:

From [email protected] Sat Jan 5 09:14:16 2008

You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a count at the end.

Hint: make sure not to include the lines that start with 'From:'.

if line.startswith('From') :

if line[4] is ':' :

req_line = line.split()

print(req_line[1])

print('There were',count, 'lines in the file with From as the first word')

==============================================================================================

Week 5 - Assignment 9.4

Write a program to read through the mbox-short.txt and figure out who has sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count of the number of times they appear in the file. After the dictionary is produced, the program reads through the dictionary using a maximum loop to find the most prolific committer.

reg_mailer = dict() # regular mailer

mail = words[1]

# reg_mailer[mail] = reg_mailer.get(mail,0) + 1

if reg_mailer is None or mail not in reg_mailer :

reg_mailer[mail] = 1

reg_mailer[mail] = reg_mailer[mail] + 1

a = max(reg_mailer.values())

for key, value in reg_mailer.items() :

if value == a :

print(key,a)

Week 6 - Assignment 10.2

Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages.

You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon.

Once you have accumulated the counts for each hour, print out the counts, sorted by hour as shown below.

time_mail = dict()

time = words[5]

time_tup = time.split(':')

time_tuple = time_tup[0]

time_mail[time_tuple] = time_mail.get(time_tuple,0) + 1

# if reg_mailer is None or mail not in reg_mailer :

# reg_mailer[mail] = 1

# reg_mailer[mail] = reg_mailer[mail] + 1

ans = sorted(time_mail.items())

for k,v in ans:

curi0us s0ul

assignment 7.1 python data structures

python data structures chapter 7.1 assignment

  • python repetition structures
  • mac big sur and python3 problems
  • python 0-1 kanpsack
  • logical operators python
  • Python For Data Science And Machine Learning Bootcamp
  • python practice problems
  • class item assignment python
  • assignment 4.6 python for everybody
  • assignment 6.5 python for everybody
  • cors assignment 4.6 python
  • python data structures
  • advanced python course
  • python fundamentals assignment solutions pdf
  • python data structures 9.4
  • python beginner practice problems
  • learn python the hard way pdf
  • data structures and algorithms in python
  • python for data science

python data structures chapter 7.1 assignment

New to Communities?

python data structures chapter 7.1 assignment

logo

Python Numerical Methods

../_images/book_cover.jpg

This notebook contains an excerpt from the Python Programming and Numerical Methods - A Guide for Engineers and Scientists , the content is also available at Berkeley Python Numerical Methods .

The copyright of the book belongs to Elsevier. We also have this interactive book online for a better learning experience. The code is released under the MIT license . If you find this content useful, please consider supporting the work on Elsevier or Amazon !

< Chapter 6 Summary and Problems | Contents | 7.1 Introduction to OOP >

Chapter 7. Object Oriented Programming (OOP) ¶

Chapter outline ¶.

7.1 Introduction to OOP

7.2 Class and Object

7.3 Inheritance, Encapsulation and Polymorphism

7.4 Summary and Problems

Motivation ¶

As demonstrated earlier, often we need to use other packages, such as scipy , numpy , or other domain specified packages. When you check the source code of these packages, you may see new keywords in the code, such as class . What are classes and why do we use them? This is a new programming paradigm - Object-Oriented Programming (OOP) that is commonly used in writing large programs or packages. When writing a large program, OOP has a number of pluses: it simplifies the code for better readability, better describes the end goal of the project, is reusable, and reduces the number of potential bugs in the code. Given these features, you will see OOP in most of the standard packages in the field. Understanding its basics will help you write better code. This chapter introduces the basics of OOP, with emphasis on the core components: object, class, and inheritance, . Python is a highly object-oriented programming language and understanding these concepts will help you program with a minimum amount of headaches.

  • Python »
  • 3.12.3 Documentation »
  • The Python Tutorial »
  • 5. Data Structures
  • Theme Auto Light Dark |

5. Data Structures ¶

This chapter describes some things you’ve learned about already in more detail, and adds some new things as well.

5.1. More on Lists ¶

The list data type has some more methods. Here are all of the methods of list objects:

Add an item to the end of the list. Equivalent to a[len(a):] = [x] .

Extend the list by appending all the items from the iterable. Equivalent to a[len(a):] = iterable .

Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x) .

Remove the first item from the list whose value is equal to x . It raises a ValueError if there is no such item.

Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. It raises an IndexError if the list is empty or the index is outside the list range.

Remove all items from the list. Equivalent to del a[:] .

Return zero-based index in the list of the first item whose value is equal to x . Raises a ValueError if there is no such item.

The optional arguments start and end are interpreted as in the slice notation and are used to limit the search to a particular subsequence of the list. The returned index is computed relative to the beginning of the full sequence rather than the start argument.

Return the number of times x appears in the list.

Sort the items of the list in place (the arguments can be used for sort customization, see sorted() for their explanation).

Reverse the elements of the list in place.

Return a shallow copy of the list. Equivalent to a[:] .

An example that uses most of the list methods:

You might have noticed that methods like insert , remove or sort that only modify the list have no return value printed – they return the default None . [ 1 ] This is a design principle for all mutable data structures in Python.

Another thing you might notice is that not all data can be sorted or compared. For instance, [None, 'hello', 10] doesn’t sort because integers can’t be compared to strings and None can’t be compared to other types. Also, there are some types that don’t have a defined ordering relation. For example, 3+4j < 5+7j isn’t a valid comparison.

5.1.1. Using Lists as Stacks ¶

The list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (“last-in, first-out”). To add an item to the top of the stack, use append() . To retrieve an item from the top of the stack, use pop() without an explicit index. For example:

5.1.2. Using Lists as Queues ¶

It is also possible to use a list as a queue, where the first element added is the first element retrieved (“first-in, first-out”); however, lists are not efficient for this purpose. While appends and pops from the end of list are fast, doing inserts or pops from the beginning of a list is slow (because all of the other elements have to be shifted by one).

To implement a queue, use collections.deque which was designed to have fast appends and pops from both ends. For example:

5.1.3. List Comprehensions ¶

List comprehensions provide a concise way to create lists. Common applications are to make new lists where each element is the result of some operations applied to each member of another sequence or iterable, or to create a subsequence of those elements that satisfy a certain condition.

For example, assume we want to create a list of squares, like:

Note that this creates (or overwrites) a variable named x that still exists after the loop completes. We can calculate the list of squares without any side effects using:

or, equivalently:

which is more concise and readable.

A list comprehension consists of brackets containing an expression followed by a for clause, then zero or more for or if clauses. The result will be a new list resulting from evaluating the expression in the context of the for and if clauses which follow it. For example, this listcomp combines the elements of two lists if they are not equal:

and it’s equivalent to:

Note how the order of the for and if statements is the same in both these snippets.

If the expression is a tuple (e.g. the (x, y) in the previous example), it must be parenthesized.

List comprehensions can contain complex expressions and nested functions:

5.1.4. Nested List Comprehensions ¶

The initial expression in a list comprehension can be any arbitrary expression, including another list comprehension.

Consider the following example of a 3x4 matrix implemented as a list of 3 lists of length 4:

The following list comprehension will transpose rows and columns:

As we saw in the previous section, the inner list comprehension is evaluated in the context of the for that follows it, so this example is equivalent to:

which, in turn, is the same as:

In the real world, you should prefer built-in functions to complex flow statements. The zip() function would do a great job for this use case:

See Unpacking Argument Lists for details on the asterisk in this line.

5.2. The del statement ¶

There is a way to remove an item from a list given its index instead of its value: the del statement. This differs from the pop() method which returns a value. The del statement can also be used to remove slices from a list or clear the entire list (which we did earlier by assignment of an empty list to the slice). For example:

del can also be used to delete entire variables:

Referencing the name a hereafter is an error (at least until another value is assigned to it). We’ll find other uses for del later.

5.3. Tuples and Sequences ¶

We saw that lists and strings have many common properties, such as indexing and slicing operations. They are two examples of sequence data types (see Sequence Types — list, tuple, range ). Since Python is an evolving language, other sequence data types may be added. There is also another standard sequence data type: the tuple .

A tuple consists of a number of values separated by commas, for instance:

As you see, on output tuples are always enclosed in parentheses, so that nested tuples are interpreted correctly; they may be input with or without surrounding parentheses, although often parentheses are necessary anyway (if the tuple is part of a larger expression). It is not possible to assign to the individual items of a tuple, however it is possible to create tuples which contain mutable objects, such as lists.

Though tuples may seem similar to lists, they are often used in different situations and for different purposes. Tuples are immutable , and usually contain a heterogeneous sequence of elements that are accessed via unpacking (see later in this section) or indexing (or even by attribute in the case of namedtuples ). Lists are mutable , and their elements are usually homogeneous and are accessed by iterating over the list.

A special problem is the construction of tuples containing 0 or 1 items: the syntax has some extra quirks to accommodate these. Empty tuples are constructed by an empty pair of parentheses; a tuple with one item is constructed by following a value with a comma (it is not sufficient to enclose a single value in parentheses). Ugly, but effective. For example:

The statement t = 12345, 54321, 'hello!' is an example of tuple packing : the values 12345 , 54321 and 'hello!' are packed together in a tuple. The reverse operation is also possible:

This is called, appropriately enough, sequence unpacking and works for any sequence on the right-hand side. Sequence unpacking requires that there are as many variables on the left side of the equals sign as there are elements in the sequence. Note that multiple assignment is really just a combination of tuple packing and sequence unpacking.

5.4. Sets ¶

Python also includes a data type for sets . A set is an unordered collection with no duplicate elements. Basic uses include membership testing and eliminating duplicate entries. Set objects also support mathematical operations like union, intersection, difference, and symmetric difference.

Curly braces or the set() function can be used to create sets. Note: to create an empty set you have to use set() , not {} ; the latter creates an empty dictionary, a data structure that we discuss in the next section.

Here is a brief demonstration:

Similarly to list comprehensions , set comprehensions are also supported:

5.5. Dictionaries ¶

Another useful data type built into Python is the dictionary (see Mapping Types — dict ). Dictionaries are sometimes found in other languages as “associative memories” or “associative arrays”. Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys , which can be any immutable type; strings and numbers can always be keys. Tuples can be used as keys if they contain only strings, numbers, or tuples; if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key. You can’t use lists as keys, since lists can be modified in place using index assignments, slice assignments, or methods like append() and extend() .

It is best to think of a dictionary as a set of key: value pairs, with the requirement that the keys are unique (within one dictionary). A pair of braces creates an empty dictionary: {} . Placing a comma-separated list of key:value pairs within the braces adds initial key:value pairs to the dictionary; this is also the way dictionaries are written on output.

The main operations on a dictionary are storing a value with some key and extracting the value given the key. It is also possible to delete a key:value pair with del . If you store using a key that is already in use, the old value associated with that key is forgotten. It is an error to extract a value using a non-existent key.

Performing list(d) on a dictionary returns a list of all the keys used in the dictionary, in insertion order (if you want it sorted, just use sorted(d) instead). To check whether a single key is in the dictionary, use the in keyword.

Here is a small example using a dictionary:

The dict() constructor builds dictionaries directly from sequences of key-value pairs:

In addition, dict comprehensions can be used to create dictionaries from arbitrary key and value expressions:

When the keys are simple strings, it is sometimes easier to specify pairs using keyword arguments:

5.6. Looping Techniques ¶

When looping through dictionaries, the key and corresponding value can be retrieved at the same time using the items() method.

When looping through a sequence, the position index and corresponding value can be retrieved at the same time using the enumerate() function.

To loop over two or more sequences at the same time, the entries can be paired with the zip() function.

To loop over a sequence in reverse, first specify the sequence in a forward direction and then call the reversed() function.

To loop over a sequence in sorted order, use the sorted() function which returns a new sorted list while leaving the source unaltered.

Using set() on a sequence eliminates duplicate elements. The use of sorted() in combination with set() over a sequence is an idiomatic way to loop over unique elements of the sequence in sorted order.

It is sometimes tempting to change a list while you are looping over it; however, it is often simpler and safer to create a new list instead.

5.7. More on Conditions ¶

The conditions used in while and if statements can contain any operators, not just comparisons.

The comparison operators in and not in are membership tests that determine whether a value is in (or not in) a container. The operators is and is not compare whether two objects are really the same object. All comparison operators have the same priority, which is lower than that of all numerical operators.

Comparisons can be chained. For example, a < b == c tests whether a is less than b and moreover b equals c .

Comparisons may be combined using the Boolean operators and and or , and the outcome of a comparison (or of any other Boolean expression) may be negated with not . These have lower priorities than comparison operators; between them, not has the highest priority and or the lowest, so that A and not B or C is equivalent to (A and (not B)) or C . As always, parentheses can be used to express the desired composition.

The Boolean operators and and or are so-called short-circuit operators: their arguments are evaluated from left to right, and evaluation stops as soon as the outcome is determined. For example, if A and C are true but B is false, A and B and C does not evaluate the expression C . When used as a general value and not as a Boolean, the return value of a short-circuit operator is the last evaluated argument.

It is possible to assign the result of a comparison or other Boolean expression to a variable. For example,

Note that in Python, unlike C, assignment inside expressions must be done explicitly with the walrus operator := . This avoids a common class of problems encountered in C programs: typing = in an expression when == was intended.

5.8. Comparing Sequences and Other Types ¶

Sequence objects typically may be compared to other objects with the same sequence type. The comparison uses lexicographical ordering: first the first two items are compared, and if they differ this determines the outcome of the comparison; if they are equal, the next two items are compared, and so on, until either sequence is exhausted. If two items to be compared are themselves sequences of the same type, the lexicographical comparison is carried out recursively. If all items of two sequences compare equal, the sequences are considered equal. If one sequence is an initial sub-sequence of the other, the shorter sequence is the smaller (lesser) one. Lexicographical ordering for strings uses the Unicode code point number to order individual characters. Some examples of comparisons between sequences of the same type:

Note that comparing objects of different types with < or > is legal provided that the objects have appropriate comparison methods. For example, mixed numeric types are compared according to their numeric value, so 0 equals 0.0, etc. Otherwise, rather than providing an arbitrary ordering, the interpreter will raise a TypeError exception.

Table of Contents

  • 5.1.1. Using Lists as Stacks
  • 5.1.2. Using Lists as Queues
  • 5.1.3. List Comprehensions
  • 5.1.4. Nested List Comprehensions
  • 5.2. The del statement
  • 5.3. Tuples and Sequences
  • 5.5. Dictionaries
  • 5.6. Looping Techniques
  • 5.7. More on Conditions
  • 5.8. Comparing Sequences and Other Types

Previous topic

4. More Control Flow Tools

  • Report a Bug
  • Show Source

Auroras Technological and Research Institute

  • Top Courses

Auroras Technological and Research Institute

Python Data Structures

This course is part of Python for Everybody Specialization

Taught in English

Some content may not be translated

Charles Russell Severance

Instructor: Charles Russell Severance

Sponsored by Auroras Technological and Research Institute

1,036,086 already enrolled

(94,874 reviews)

What you'll learn

Explain the principles of data structures & how they are used

Create programs that are able to read and write data from files

Store data as key/value pairs using Python dictionaries

Accomplish multi-step tasks like sorting or looping using tuples

Skills you'll gain

  • Computer Programming
  • Computer Programming Tools
  • Data Analysis
  • Data Management
  • Data Structures
  • Problem Solving
  • Programming Principles
  • Python Programming
  • Software Engineering

Details to know

python data structures chapter 7.1 assignment

Add to your LinkedIn profile

See how employees at top companies are mastering in-demand skills

Placeholder

Build your subject-matter expertise

  • Learn new concepts from industry experts
  • Gain a foundational understanding of a subject or tool
  • Develop job-relevant skills with hands-on projects
  • Earn a shareable career certificate

Placeholder

Earn a career certificate

Add this credential to your LinkedIn profile, resume, or CV

Share it on social media and in your performance review

Placeholder

There are 7 modules in this course

This course will introduce the core data structures of the Python programming language. We will move past the basics of procedural programming and explore how we can use the Python built-in data structures such as lists, dictionaries, and tuples to perform increasingly complex data analysis. This course will cover Chapters 6-10 of the textbook “Python for Everybody”. This course covers Python 3.

Chapter Six: Strings

In this class, we pick up where we left off in the previous class, starting in Chapter 6 of the textbook and covering Strings and moving into data structures. The second week of this class is dedicated to getting Python installed if you want to actually run the applications on your desktop or laptop. If you choose not to install Python, you can just skip to the third week and get a head start.

What's included

7 videos 7 readings 1 quiz 1 app item

7 videos • Total 57 minutes

  • Video Welcome - Dr. Chuck • 1 minute • Preview module
  • 6.1 - Strings • 15 minutes
  • 6.2 - Manipulating Strings • 17 minutes
  • Worked Exercise: 6.5 • 8 minutes
  • Bonus: Office Hours New York City • 2 minutes
  • Bonus: Monash Museum of Computing History • 7 minutes
  • Fun: The Textbook Authors Meet @PyCon • 3 minutes

7 readings • Total 70 minutes

  • Reading: Welcome to Python Data Structures • 10 minutes
  • Help Us Learn More About You! • 10 minutes
  • Course Syllabus • 10 minutes
  • Textbook • 10 minutes
  • Submitting Assignments • 10 minutes
  • Notice for Auditing Learners: Assignment Submission • 10 minutes
  • Audio Versions of All Lectures • 10 minutes

1 quiz • Total 30 minutes

  • Chapter 6 Quiz • 30 minutes

1 app item • Total 60 minutes

  • Assignment 6.5 • 60 minutes

Unit: Installing and Using Python

In this module you will set things up so you can write Python programs. We do not require installation of Python for this class. You can write and test Python programs in the browser using the "Python Code Playground" in this lesson. Please read the "Using Python in this Class" material for details.

5 videos 2 readings 1 peer review 1 app item

5 videos • Total 26 minutes

  • Demonstration: Using the Python Playground • 3 minutes • Preview module
  • Windows 10: Installing Python and Writing A Program • 6 minutes
  • Windows: Taking Screen Shots • 2 minutes
  • Macintosh: Using Python and Writing A Program • 9 minutes
  • Macintosh: Taking Screen Shots • 4 minutes

2 readings • Total 20 minutes

  • Important Reading: Using Python in this Class • 10 minutes
  • Notes on Choice of Text Editor • 10 minutes

1 peer review • Total 60 minutes

  • Optional- Installing Python Screen Shots • 60 minutes
  • Python Code Playground • 60 minutes

Chapter Seven: Files

Up to now, we have been working with data that is read from the user or data in constants. But real programs process much larger amounts of data by reading and writing files on the secondary storage on your computer. In this chapter we start to write our first programs that read, scan, and process real data.

5 videos 1 reading 1 quiz 2 app items

5 videos • Total 46 minutes

  • 7.1 - Files • 8 minutes • Preview module
  • 7.2 - Processing Files • 11 minutes
  • Demonstration: Worked Exercise 7.1 • 9 minutes
  • Bonus: Office Hours Barcelona • 1 minute
  • Bonus: Gordon Bell - Building Blocks of Computing • 15 minutes

1 reading • Total 10 minutes

  • Where is the 7.2 worked exercise? • 10 minutes
  • Chapter 7 Quiz • 30 minutes

2 app items • Total 120 minutes

  • Assignment 7.1 • 60 minutes
  • Assignment 7.2 • 60 minutes

Chapter Eight: Lists

As we want to solve more complex problems in Python, we need more powerful variables. Up to now we have been using simple variables to store numbers or strings where we have a single value in a variable. Starting with lists we will store many values in a single variable using an indexing scheme to store, organize, and retrieve different values from within a single variable. We call these multi-valued variables "collections" or "data structures".

7 videos 1 quiz 2 app items

7 videos • Total 47 minutes

  • 8.1 - Lists • 10 minutes • Preview module
  • 8.2 - Manipulating Lists • 9 minutes
  • 8.3 - Lists and Strings • 7 minutes
  • Fun: Python Lists in Paris • 0 minutes
  • Worked Exercise: Lists • 11 minutes
  • Bonus: Office Hours - Chicago • 0 minutes
  • Bonus: Rasmus Lerdorf - Inventing the PHP Language • 7 minutes
  • Chapter 8 Quiz • 30 minutes
  • Assignment 8.4 • 60 minutes
  • Assignment 8.5 • 60 minutes

Chapter Nine: Dictionaries

The Python dictionary is one of its most powerful data structures. Instead of representing values in a linear list, dictionaries store data as key / value pairs. Using key / value pairs gives us a simple in-memory "database" in a single Python variable.

7 videos 1 quiz 1 app item

7 videos • Total 75 minutes

  • 9.1 - Dictionaries • 9 minutes • Preview module
  • 9.2 - Counting with Dictionaries • 8 minutes
  • 9.3 - Dictionaries and Files • 13 minutes
  • Worked Exercise: Dictionaries • 26 minutes
  • Bonus: Office Hours - Amsterdam • 3 minutes
  • Bonus: Brendan Eich - Inventing Javascript • 11 minutes
  • Fun: Dr. Chuck Goes Motocross Racing • 2 minutes
  • Chapter 9 Quiz • 30 minutes
  • Assignment 9.4 • 60 minutes

Chapter Ten: Tuples

Tuples are our third and final basic Python data structure. Tuples are a simple version of lists. We often use tuples in conjunction with dictionaries to accomplish multi-step tasks like sorting or looping through all of the data in a dictionary.

6 videos 1 quiz 1 app item

6 videos • Total 51 minutes

  • 10 - Tuples • 17 minutes • Preview module
  • Worked Exercise: Tuples and Sorting • 12 minutes
  • Bonus: Office Hours - Puebla, Mexico • 1 minute
  • Bonus: John Resig - Inventing JQuery • 10 minutes
  • Douglas Crockford: JavaScript Object Notation (JSON) • 7 minutes
  • Fun: The Greatest Taco in the World • 2 minutes
  • Chapter 10 Quiz • 30 minutes
  • Assignment 10.2 • 60 minutes

To celebrate your making it to the halfway point in our Python for Everybody Specialization, we welcome you to attend our online graduation ceremony. It is not very long, and it features a Commencement speaker and very short commencement speech.

2 videos 2 readings

2 videos • Total 16 minutes

  • Graduation Ceremony • 7 minutes • Preview module
  • Dr.Chuck Wrap Up/What's Next • 8 minutes
  • Please Rate this Course on Class-Central • 10 minutes
  • Post-Course Survey • 10 minutes

Instructor ratings

We asked all learners to give feedback on our instructors based on the quality of their teaching style.

python data structures chapter 7.1 assignment

The mission of the University of Michigan is to serve the people of Michigan and the world through preeminence in creating, communicating, preserving and applying knowledge, art, and academic values, and in developing leaders and citizens who will challenge the present and enrich the future.

Why people choose Coursera for their career

python data structures chapter 7.1 assignment

Learner reviews

Showing 3 of 94874

94,874 reviews

Reviewed on Jul 7, 2020

it was amazing course and i'm really exited to go for more courses for python data science and web development with the instructions of Dr.chuck ... thanks for this course and it was very learnable..

Reviewed on Oct 8, 2017

assignment 9.4 auto grader not working .

LTI unable to launch. error message: This tool should be launched from a learning system using LTI. i am using chrome on mac book air 2 and python 3.6

Reviewed on Aug 18, 2017

i have learned what exact python is now on this stage i can program in python and i recommend everyone want to study about the python to take this course and experienced and really thanks to Dr. CHUCK

Recommended if you're interested in Computer Science

python data structures chapter 7.1 assignment

University of Michigan

Using Python to Access Web Data

python data structures chapter 7.1 assignment

Using Databases with Python

python data structures chapter 7.1 assignment

Capstone: Retrieving, Processing, and Visualizing Data with Python

python data structures chapter 7.1 assignment

Programming for Everybody (Getting Started with Python)

Make progress toward a degree

Placeholder

Open new doors with Coursera Plus

Unlimited access to 7,000+ world-class courses, hands-on projects, and job-ready certificate programs - all included in your subscription

Advance your career with an online degree

Earn a degree from world-class universities - 100% online

Join over 3,400 global companies that choose Coursera for Business

Upskill your employees to excel in the digital economy

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

python data structures chapter 7.1 assignment

assignment 7.1 python data structures

Code examples.

  • answer assignment 7.1 python data structures
  • related assignment 8.4 python data structures

More Related Answers

Answers matrix view full screen.

python data structures chapter 7.1 assignment

Closely Related Answers

Assignment 8.4 python data structures.

Trinetra Banerjee

Documentation

Twitter Logo

Oops, You will need to install Grepper and log-in to perform this action.

Search This Blog

Ashvini sharma.

Hello dosto! Welcome to my Blog . I am so happy to visit my blog. In this blog you can find your maximum information as like related to Coursera in, you find all quiz and assignment weekly as your course embedded.

Python data structures: Assignment 7.1

python data structures chapter 7.1 assignment

Would this work on a Mac? I am getting the following error message IOError: [Errno 2] No such file or directory: 'Word.txt' on line 3

Post a Comment

Comments here for more information.........

Popular posts from this blog

Python data structure: assignment 8.4, programming for everybody (python) assignment 5.2, coursera:web application technologies and django.

Image

Python data structures Chapter 6 Quiz

Image

IMAGES

  1. Python Programming

    python data structures chapter 7.1 assignment

  2. Python Data Structures Cheat Sheet by prl1007

    python data structures chapter 7.1 assignment

  3. NPTEL Programming Data Structures And Algorithms Using Python Week 1 Assignment |@OPEducore

    python data structures chapter 7.1 assignment

  4. An introduction to python data structures

    python data structures chapter 7.1 assignment

  5. Python Data Structure- Part 1

    python data structures chapter 7.1 assignment

  6. Structure Of Python

    python data structures chapter 7.1 assignment

VIDEO

  1. 10-Data structure using python Chapter 7 Linked List-part 1

  2. Python Data Structures

  3. Assignment 9.4 Python Data Structures

  4. Programming, Data Structures and Algorithms using Python || NPTEL week 1 answers 2024 || #nptel

  5. 14.Python Advanced Data structures

  6. 4.2. Python Data structures sets,dictionaries

COMMENTS

  1. Coursera-PY4E-Python-Data-Structures/Assignment-7.1 at master ...

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window.

  2. Coursera-Python-Data-Structures/Week 3 Assignment 7.1-solution ...

    My solutions to all quizzes and assignments for Python Data Structures on coursera by the University of Michigan - Coursera-Python-Data-Structures/Week 3 Assignment 7.1-solution.py at master · pavanayila/Coursera-Python-Data-Structures

  3. python-for-everybody/wk7

    python-for-everybody. /. wk7 - assignment 7.1.py. Cannot retrieve latest commit at this time. History. Code. Blame. 12 lines (9 loc) · 448 Bytes. 7.1 Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file in upper case.

  4. Python Data Structures Assignment 7.1 Solution [Coursera ...

    Python Data Structures Assignment 7.1 Solution [Coursera] | Assignment 7.1 Python Data StructuresCoursera: Programming For Everybody Assignment 7.1 program s...

  5. assignment 7.1 python data structures

    Some of the most commonly used data structures are lists, tuples, sets, and dictionaries. Here are some examples of how you can use each of these data structures in Python: 1. Lists: A list is a collection of items that are ordered and changeable. You can create a list in Python by enclosing a comma-separated sequence of items within square ...

  6. chapter 7 week 3 Assignment 7.1

    10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon.

  7. Python Data Structures

    This course will introduce the core data structures of the Python programming language. We will move past the basics of procedural programming and explore how we can use the Python built-in data structures such as lists, dictionaries, and tuples to perform increasingly complex data analysis. This course will cover Chapters 6-10 of the textbook ...

  8. Python Data Structures Assignment 7.1 Solution [Coursera ...

    Python Data Structures Assignment 7.1 Solution [Coursera] | Assignment 7.1 Python Data StructuresPython Data Structures Assignment 7.1 Solution [Coursera] | ...

  9. Coursera:- 7.1 assignment solution//Data structures ...

    # Coursera :- #python data structures# Python👇👇program run code 👇👇https://1drv.ms/w/s!AspSlroH33QifAdPaMMP5CG9bwECHAPTER :- PYTHON DATA STRUCTURESASSIGN...

  10. PYTHON DATA STRUCTURES Assignment 7.1 [coursera]

    ..Welcome to #mythoughtsPYTHON DATA STRUCTURES Assignment 7.1 [coursera] | Assignment 7.1 in PYHTON DATA STRUCTURES |Assignment 7.1 in PY4E |

  11. 7. Extending Data Structures

    Intro to Python Textbook. 1. Python and Console Interaction ... Functions and Exceptions. 5. Strings. 6. Creating and Altering Data Structure. 7. Extending Data Structures. 7.1 2D Lists. 7.2 List Comprehensions. 7.3 Packing and Unpacking. 7.4 Dictionaries. 7.5 Equivalence vs. Identity. 7.6 Conclusion. Chapter 7. Extending Data Structures. 7.1 ...

  12. N. Lokesh Reddy

    Assignment 7.2. Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: X-DSPAM-Confidence: 0.8475. Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below.

  13. assignment 7.1 python data structures

    Get code examples like"assignment 7.1 python data structures". Write more code and save time using our ready-made code examples.

  14. Chapter 7. Object Oriented Programming (OOP)

    This is a new programming paradigm - Object-Oriented Programming (OOP) that is commonly used in writing large programs or packages. When writing a large program, OOP has a number of pluses: it simplifies the code for better readability, better describes the end goal of the project, is reusable, and reduces the number of potential bugs in the code.

  15. 5. Data Structures

    Data Structures¶ This chapter describes some things you've learned about already in more detail, and adds some new things as well. 5.1. More on Lists¶ The list data type has some more methods. Here are all of the methods of list objects: list. append (x) Add an item to the end of the list. Equivalent to a[len(a):] = [x]. list. extend (iterable)

  16. Python Data Structures

    This course will introduce the core data structures of the Python programming language. We will move past the basics of procedural programming and explore how we can use the Python built-in data structures such as lists, dictionaries, and tuples to perform increasingly complex data analysis. This course will cover Chapters 6-10 of the textbook ...

  17. Coursera---Python-Data-Structure-Answers/Assignment 7.1 ...

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window.

  18. {"payload":{"allShortcutsEnabled":false,"fileTree":{"Week-3":{"items

    {"payload":{"allShortcutsEnabled":false,"fileTree":{"Week-3":{"items":[{"name":"Assignment7.1.py","path":"Week-3/Assignment7.1.py","contentType":"file"},{"name ...

  19. Assignment 7.1.py

    View Homework Help - Assignment 7.1.py from CS 100 at Coursera. " 7.1 Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file

  20. PDF Introduction to Python® Programming and Data Structures

    2.8 Numeric Data Types and Operators 2.9 Case Study: Minimum Number of Changes 2.10 Evaluating Expressions and Operator Precedence 2.11 Augmented Assignment Operators 2.12 Type Conversions and Rounding 2.13 Case Study: Displaying the Current Time 2.14 Software Development Process 2.15 Case Study: Computing Distances Chapter 3. Selections 3.1 ...

  21. PYTHON DATA STRUCTURE (Assignment-7.1)- COURSERA

    About Press Copyright Contact us Creators Advertise Developers Terms Privacy Policy & Safety How YouTube works Test new features NFL Sunday Ticket Press Copyright ...

  22. assignment 7.1 python data structures

    assignment 7.1 python data structures Comment . 0. Popularity 8/10 Helpfulness 6/10 Language python. Source: Grepper. Tags: data-structures python. Share . Link to this answer Share Copy Link . Contributed on Aug 27 2020 . Comfortable Cod. 0 Answers Avg Quality 2/10 ...

  23. Python data structures: Assignment 7.1

    Coursera : Python data structures Assignment 8.4 Week 4 8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list.