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 3AW
Program Plan Intro
Copying lists:
- • In Python, to copy data items in one list to another list, just simply assign the list to be copied to another list.
- • Both lists will be similar, as they refer to the identical object in the memory.
Algorithm to copy the values in one list to another is as follows:
- • Create a list named “number1” with 100 data items.
- • Create an empty list named “number2”.
- • Assign the list “number1” to the empty list “number2” to copy the 100 data elements from “number1” to “number2”.
- • Print the lists “number1” and “number2” using the “print()” function.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
paython programing question
Write a program that creates a list of N elements (Hint: use append() function), swaps the first and the last element and prints the list on the screen. N should be a dynamic number entered by the user.
Sample output:
How many numbers would you like to enter?: 5
Enter a number: 34
Enter a number: 67
Enter a number: 23
Enter a number: 90
Enter a number: 12
The list is: [12, 67,23, 90, 34]
2.
ID: A
Name:
2. A list of numbers is considered increasing if each value after the first is greater than or equal to the preceding
value. The following procedure is intended to return true if numberList is increasing and return false
otherwise. Assume that numberList contains at least two elements.
Line 1:
PROCEDURE isIncreasing (numberList)
Line 2: {
Line 3:
count 2
Line 4:
REPEAT UNTIL(count > LENGTH(numberList))
Line 5:
Line 6:
IF(numberList[count] =.
YA198IC
Need pseudocode for this
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
- Indexing in a list is accomplished by specifying a position number, in brackets, to access a particular element. True or false?arrow_forwardComplete the following function that creates a duplicate version of a list but with the elements stored in reverse order from the original. 1 def reverseOrder (origValues): newValues = [] 1234567 # Add the elements from the origValues List to newValues, in reverse order. # Your code goes here return newValuesarrow_forwardIN PYTHON: DO NOT USE ENUMERATE OR NUMPY Write the following function that returns the location of the largest element in a two-dimensional list: def locateLargest(a): The return value is a one-dimensional list that contains two elements. These two elements indicate the row and column indexes of the largest element in the two-dimensional list. Write a test program that prompts the user to enter a two dimensional list and displays the location of the largest element in the list. Sample Run: Enter the number of rows in the list: 3 Enter a row: 20.6 40 1 4 Enter a row: 5.5 3 42 4.5 Enter a row: 46 32 4.4 12.1 The loacation of the largest element is at (0,2)arrow_forward
- in PYTHON Write a function that accepts a list as an argument and calculates the sum of each elementof the list.arrow_forwardOCaml Code: Attached are the instructions. Make sure to read the instructions carefully and write your own test cases to make sure the code works. Make sure to include a screenshot of the correct code with the test cases that is used along with the output of the code being passed.arrow_forwardInteger m and string my_name are read from input. Then, four strings are read from input and stored in the list names_data. Delete the first element in names_data, and then replace the element at index m with my_name.arrow_forward
- debugg help def print_categories(main_list): if id not in main_list: print("There are no categories.") return 0 idx = 0 for items in main_list: item = items[i:] print("{idx + 1} . {item[0]} - {item[1]}%") idx += 1 return idx """ Given a list of lists, for each list stored in main_list, output its contents as follows: f"{index of category}. {item[0]} - {item[1]}%". note that indexing must start at 1 for the first item, not 0, which is first item's actual index in main_list. If `main_list` is empty, the function prints "There are no categories." Returns the number of categories. """ def is_valid_index(idx, in_list): if (idx in in_list - 1): if len(idx) != 0: """ Checks whether the provided index `idx` is a valid positive index that can retrieve an element from `in_list`. Returns False if `idx` is negative or exceeds the size of…arrow_forwardPYTHON CODE - WRITE PYTHON FUNCTIONarrow_forwardWrite a statement that will print the first letter of each element of the following list: list1 = [‘Galileo’,‘Oliver’,’Ostwald’,’Descartes’].arrow_forward
- 3. A list of numbers is considered increasing if each value after the first is greater than or equal to the preceding value. The following procedure is intended to return true if numberList is increasing and return false otherwise. Assume that numberList contains at least two elements. PROCEDURE isIncreasing(numberList) Tue 61 Line 1: Line 2: { Line 3: count 2 Line 4: REPEAT UNTIL(count > LENGTH(numberList)) Line 5: } IF(numberList[count] =. a. b. Lines 10 and 11 should be interchanged. d. In line 3, 2 should be changed to 1. 3.arrow_forwardCreate a list of Employees (List can be as long as user wants). Program should save the following information for each Employee: Name, Emp. No., Experience, Designation and Salary. Now perform the following tasks:Lab 2: List Implementation using ArraysDepartment of Computer Science Page 27MAJU, Islamabada) Your program should save the information of only those employees whose experience is atleast 2 years.b) Display only those Employees whose Salary is greater than 50,000c) Display the Employees alphabeticallyarrow_forwardIn order to print each item in a list, create a function called Multiply2 that multiplies the list's elements by 2. For instance: mylist=[1,2,3,4] In this case, multiply2(mylist) returns the following results: 2 4 6 8 The function requires just one argument, which is the list on which the operation is to be done.arrow_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