Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 7.8, Problem 19CP
Program Plan Intro
Two-dimensional list:
- • A list that has another list as its elements is called as two-dimensional list.
- • Two-dimensional list is a type of nested list, where elements are arranged in row and column order.
- • The element in the list is retrieved using two subscripts. One subscript specifies the row and the other subscript specifies the column.
- • The two-dimensional lists are helpful in processing various sets of information.
Syntax:
In Python, two-dimensional lists have the below format:
List_name = [list1,list2, …, listn]
Explanation:
Here,
- • The variable “List_name” is a two-dimensional list.
- • The variables “list1”, “list2”, and “listn” are elements of two-dimensional list “List_name” that indicates one-dimensional lists.
Example:
Consider the following example that shows a two-dimensional list.
student_scores = [[45, 63, 72], [81, 58, 97], [100, 23, 67]]
Explanation:
In the given above code,
- • The variable “student_scores” is a two-dimensional list that stores the students’ scores at various exams.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Given a nested list named NxN_table that represents a table with N rows and N columns, print each element that is along the diagonal of the table starting from the upper left corner moving down to the lower right corner.
Hint: You only need to use one loop. Draw a nested list that has three sublists each containing 3 elements.
What are the indexes of the elements along the diagonal?
Look at the following interactive session, in which a two-dimensional list is created. How many rows and how many columns are in the list? numbers = [[1, 2], [10, 20], [100, 200], [1000, 2000]]
A list contains elements is false in python.
True or false?
Chapter 7 Solutions
Starting Out with Python (4th Edition)
Ch. 7.2 - What will the following code display? numbers =...Ch. 7.2 - Prob. 2CPCh. 7.2 - Prob. 3CPCh. 7.2 - Prob. 4CPCh. 7.2 - Prob. 5CPCh. 7.2 - Prob. 6CPCh. 7.2 - Prob. 7CPCh. 7.2 - Prob. 8CPCh. 7.3 - Prob. 9CPCh. 7.3 - Prob. 10CP
Ch. 7.3 - Prob. 11CPCh. 7.3 - Prob. 12CPCh. 7.3 - Prob. 13CPCh. 7.4 - What will the following code display? names =...Ch. 7.5 - Prob. 15CPCh. 7.5 - Prob. 16CPCh. 7.5 - Prob. 17CPCh. 7.5 - Prob. 18CPCh. 7.8 - Prob. 19CPCh. 7.8 - Prob. 20CPCh. 7.8 - Write a set of nested loops that display the...Ch. 7.9 - Prob. 22CPCh. 7.9 - Prob. 23CPCh. 7.9 - Prob. 24CPCh. 7.9 - Prob. 25CPCh. 7.10 - Prob. 26CPCh. 7.10 - Prob. 27CPCh. 7.10 - Prob. 28CPCh. 7.10 - Prob. 29CPCh. 7.10 - Prob. 30CPCh. 7.10 - To create a bar chart with the bar function, what...Ch. 7.10 - Assume the following statement calls the bar...Ch. 7.10 - Prob. 33CPCh. 7 - This term refers to an individual item in a list....Ch. 7 - This is a number that identifies an item in a...Ch. 7 - Prob. 3MCCh. 7 - This is the last index in a list. a. 1 b. 99 c. 0...Ch. 7 - This will happen if you try to use an index that...Ch. 7 - This function returns the length of a list. a....Ch. 7 - When the operator's left operand is a list and...Ch. 7 - This list method adds an item to the end of an...Ch. 7 - This removes an item at a specific index in a...Ch. 7 - Prob. 10MCCh. 7 - If you call the index method to locate an item in...Ch. 7 - Prob. 12MCCh. 7 - This file object method returns a list containing...Ch. 7 - Which of the following statement creates a tuple?...Ch. 7 - Prob. 1TFCh. 7 - Prob. 2TFCh. 7 - Prob. 3TFCh. 7 - Prob. 4TFCh. 7 - A file object's writelines method automatically...Ch. 7 - You can use the + operator to concatenate two...Ch. 7 - Prob. 7TFCh. 7 - You can remove an element from a tuple by calling...Ch. 7 - Prob. 1SACh. 7 - Prob. 2SACh. 7 - What will the following code display? values = [2,...Ch. 7 - Prob. 4SACh. 7 - Prob. 5SACh. 7 - Prob. 6SACh. 7 - Prob. 1AWCh. 7 - Prob. 2AWCh. 7 - Prob. 3AWCh. 7 - Prob. 4AWCh. 7 - Write a function that accepts a list as an...Ch. 7 - Prob. 6AWCh. 7 - Prob. 7AWCh. 7 - Prob. 8AWCh. 7 - Total Sales Design a program that asks the user to...Ch. 7 - Prob. 2PECh. 7 - Rainfall Statistics Design a program that lets the...Ch. 7 - Prob. 4PECh. 7 - Prob. 5PECh. 7 - Larger Than n In a program, write a function that...Ch. 7 - Drivers License Exam The local driver s license...Ch. 7 - Name Search If you have downloaded the source code...Ch. 7 - Prob. 9PECh. 7 - World Series Champions If you have downloaded the...Ch. 7 - Prob. 11PECh. 7 - Prob. 12PECh. 7 - Magic 8 Ball Write a program that simulates a...Ch. 7 - Expense Pie Chart Create a text file that contains...Ch. 7 - 1994 Weekly Gas Graph In the student sample...
Knowledge Booster
Similar questions
- Q1: Write a method to insert an array of elements at index in a single linked list and then display this list. The method receives this array by parameters. 12:54 AM Q2: Write a method to multiply the odd numbers and add the even numbers for a single linked list data structure, then display the results. The method receives this list by parameters. 12:54 AM Q3: Write a complete project and test it to execute the single-linked list data structure with all functions including the methods in questions 1 & 2. 12:54 AM all in javaarrow_forwardTake a look at the interactive session below, in which a two-dimensional list is generated. How many rows and columns are there in the list?[[1, 2], [[10, 20], [100, 200], [1000, 2000]]arrow_forwardThree strings are read from input and stored in the list zoo_animals. Then, three more strings are read from input and stored in the list added_animals. Create a new list called updated_animals that contains the elements of zoo_animals and added_animals, in that order.arrow_forward
- Using Java programming language create a linked list named Cars with four elements: "SUV cars", "Pickup cars", "Sport cars", and "Sedan cars". Apply the following activities on the code you’ve created and provide screen shot of each result: Add a new element “Classic car” at the beginning of the linked list using iterator. Add a new element “Economic cars" after the element "Sedan Cars" using iterator. Print the LinkedList backward from the last element to the first element using hasPrevious()arrow_forwardComputer Science Client Number Address Zipcode 123 ABC 11111 124 ABD 11112 125 ABE 11114 126 ABF 11115 I have been able to export the file to python and convert it to dataframe. DataFrama being "df". How can I write an argument, where if a Zipcode is outside of a list [11111,11112,11113,11114] then it is a red flag. Thank you!arrow_forwardWhich operation below is not part of the List interface? add an element to the list remove an element from the list replace an element in the list with another element get the size of the list grow the size of the listarrow_forward
- Use the following list to sort it and create a single linked list: 6,13,7,11,9,2,15,5,3,4,10,14 Also make a list of the available memory. Print the list out with the links. Now delete 11 from the list, adding its location to the available memory list, then add 1 and 8 to the list. When you add the 1 you should use the location of the deleted 11 to add 1 there. Add 8 to the next available spot on the available memory list. When you print the list, print out the logical list using the links and also print out physical list without the links to see what the real list looks like.arrow_forwardYou are writing a program that repeatedly does a linear search on a list of items. In order to speed the program up, every time you search for an item and find it in the list, you move that item to the beginning of the list so that the linear search will find it faster the next time you look for it. Which type of list would be better to use in this situation? Question 5 options: 1 ArrayList 2 LinkedList 3 Both types of list will perform about the same for this use casearrow_forwardSuppose a list contains the final exam results of CSE110, PHY111, and MAT110 of each student in a listed form. Your task is to sort the list based on a course name that will be given by the user and print the names after sorting. For example, a list looks likelst = [ ["Farzad",95,87,91] , ["Mahjabin",92,90,83], ["Sadman",87,92,80], ["Nakhla",85,94,90] ]where for each list, 1st index is name, 2nd index is CSE110, 3rd index is PHY111 and 4th index is MAT110. ===================================================== Hint:create a python function for sorting, then call it everytime instead of rewriting the code. Get the data in the individual lists from the given nested list. ===================================================== Sample InputMAT110 Sample OutputFarzadNakhlaMahjabinSadmanarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage