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, Problem 8AW
Program Plan Intro
Two-dimensional list:
- • A list that has another list as its elements is called as a 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 other subscript specifies the column.
Algorithm to create and fill a two-dimensional list is as follows:
- • Create a two-dimensional list called “mytwodim_list” with 5 rows and 3 columns and assign all the element values to “0”.
- • Create a nested “for” loops to fill the two-dimensional list “mytwodim_list”.
- • Inside the loop, ask the user for an integer value and store the value in the corresponding list location.
- • Print the two-dimensional list “mytwodim_list” using the “print()” function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Lottery number generator: Write a program that generates aseven-digit lottery number. The program should have a loopto generate seven random numbers, each in the range 0through 9 and assign each number to a list element.2. Write another loop to display the contents of the list.3. Tip: You will need to create/initialize your list before you canassign numbers to it.4. Use program 7-1 sales_list as an example. You will start witha seven-digit lottery number that contains all zeros. Then inyour loop, you will assign a random number instead ofgetting the data from the user.Turn in your program to the practice assignment link in coursecontent.
A list called parts has already been created and filled with data. It has a length of 5.
Write a for loop that prints each value in this list.
True/False 6. A list must contain at least one item.
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
- Create a program that allows users to enter a list of fruits. The program will also allow the user to be able to delete a fruit of choice and then print the updated listarrow_forward1. Lottery Number Generator:Design a program that generates a seven-digit lottery number. The program should generate seven random numbers, each in the range of 0 through 9, and assign each number to a list element. (Random numbers were discussed in Chapter 6.) Then write another loop that displays the contents of the list python coding pleasearrow_forwardi need to add the loop with the lists to my code can you help. see code and the part that i need to add.arrow_forward
- helparrow_forwardThe ber. nc- is . The a list with all of the use a loop to step through the list. The loop should pass each element to a function that displays the element whether it is a prime number. 13. Magic 8 Ball Write a program that simulates a Magic 8 Ball, which is a fortune-telling toy that displays a random response to a yes or no question. In the student sample programs for this book, you will find a text file named 8_ball_responses.txt. The file contains 12 responses, such as "I don't think so", "Yes, of course!", "I'm not sure", and so forth. The program should read the responses from the file into a list. It should prompt the user to ask a question, then display one of the responses, randomly selected from the list. The program should repeat until the user is ready to quit.arrow_forwardprompt user to enter a number numthis num would be set as the range the user to enter other intergers.create a list and loop to populate it with each integer the user enters up to numprint the list. Example:if num entered as 4then prompt the user to enter 4 integers. 3 6 7 9then print the list as [3, 6, 7, 9] Thank youarrow_forward
- Need pseudocode for thisarrow_forwardzeroTriples.py: Write a program that reads a list of integers from the user, until they enter -12345 (the -12345 should not be considered part of the list). Then find all triples in the list that sum to zero. You can assume the list won’t contain any duplicates, and a triple should not use the same number more than once. For example:$ python3 zeroTriples.py124-123450 triples found $ python3 zeroTriples.py-3142-123451 triple found:1, 2, -3 $ python zeroTriples.py-91-3245-4-1-123454 triples found:-9, 4, 51, -3, 2-3, 4, -15, -4, -1arrow_forwardAssume that the variable data refers to the list [5, 3, 7]. Write the expressions that perform the following tasks: a. Replace the value at position o in data with that value's negation. b. Add the value 10 to the end of data. c. Insert the value 22 at position 2 in data. d. Remove the value at position 1 in data. e. Add the values in the list newData to the end of data. f. Locate the index of the value 7 in data, safely. g. Sort the values in data.arrow_forward
- The Foreach loop iterates through the array and returns each value in the array until reaching the end of the array. What is the output of the following? $list = 0..00000000005 foreach ($item in $list) { Write-Output $item }arrow_forwardAssignment1B: Grocery List. When shopping for groceries, it's helpful to know how much it's going to cost you in advance - this helps you avoid an embarrassing situation in the check-out line. For this assignment, you're going to write a simple program that asks you for the name, quantity, and price of two grocery store items. It will then generate a grocery list for you, complete with the total price. (Later in the semester, we'll learn how to make a program that can create much larger lists, but we'll start small here). Call the file Assignment1B (with a file extension of .cpp, .cs or .java) Sample Output: What're you buying? Ice Cream How many? 2 What do they cost? 2.25 What else're you buying? Celery How many? 5 What do they cost? 1.74 Your list: Ice Cream (2) $2.25 ($4.50 total) Celery (5) $1.74 ($8.7 total) Total Cost: $13.2arrow_forwardMatich the following statements with the correct data structure by clicking on the drop down arrow and selecting the correct choice.. You need to store a list of elements and the number of elements in the program is fixed. If most of operations on a list involve retrieving an element at a given index. You have to add or delete the elements at the beginning of a list. Linked List ArrayList Arrayarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education