Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
expand_more
expand_more
format_list_bulleted
Question
Chapter 11, Problem 6PE
Program Plan Intro
Shuffling the list
- Import required package.
- Give function definition “shuffle ()” to shuffle the list.
- Create an empty list.
- Loop through the length of “myList”.
- Calculate the random value.
- Append the item to the new list.
- Remove the item from “myList”.
- Return the “newList”.
- Define the main function.
- Create a list with some values.
- Call the function “shuffle ()” by passing “myList” as the argument.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a function (Ocaml) that takes an ’a list and an int list of values and returns second list, with its integers values replaced by the values from the first vector at the position specified by the integer (indexing starts with 0). Large and negative numbers are to be skipped.
Implement a function to remove all occurrences of a specific element from a list.
(This question is for a linked list of the type described on the front page, Item 5). Write a recursive function CountGE60. that receives a linked list (may or may not be empty) and returns the number of nodes (each containing a data item value) greater than or equal to 60.
Chapter 11 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 11 - Prob. 1TFCh. 11 - Prob. 2TFCh. 11 - Prob. 3TFCh. 11 - Prob. 4TFCh. 11 - Prob. 5TFCh. 11 - Prob. 6TFCh. 11 - Prob. 7TFCh. 11 - Prob. 8TFCh. 11 - Prob. 9TFCh. 11 - Prob. 1MC
Ch. 11 - Prob. 2MCCh. 11 - Prob. 3MCCh. 11 - Prob. 4MCCh. 11 - Prob. 5MCCh. 11 - Prob. 6MCCh. 11 - Prob. 7MCCh. 11 - Prob. 8MCCh. 11 - Prob. 9MCCh. 11 - Prob. 10MCCh. 11 - Prob. 1DCh. 11 - Prob. 2DCh. 11 - Prob. 1PECh. 11 - Prob. 2PECh. 11 - Prob. 3PECh. 11 - Prob. 5PECh. 11 - Prob. 6PECh. 11 - Prob. 7PECh. 11 - Prob. 8PECh. 11 - Prob. 9PECh. 11 - Prob. 10PECh. 11 - Prob. 11PECh. 11 - Prob. 12PECh. 11 - Prob. 15PECh. 11 - Prob. 16PECh. 11 - Prob. 18PECh. 11 - Prob. 19PE
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a function that takes a list removal(L), delete from it all the elements whose indicesare divisible by 3. And return the resulting list after removing unwanted elements.Example:>>>removal(['A', 'B', 'C', 'D', 'E'])['B', 'C','E'arrow_forwardWrite a function in a racket code that takes as input a list of elements and returns a list with elements and their position after. For example, if the input to the function is (list ’a ’b ’c) then it will return (list a 1 b 2 c 3). Make sure to use recursionarrow_forwardUse clojure, define a function called remove-second that takes a list, and returns a new list that is the same as the input list, but with the second value removed. For example, given '(3 1 4), remove-second should return the list '(3 4).arrow_forward
- 1. a function that takes in a list (L), and creates a copy of L. note: The function should return a pointer to the first element in the new L. [iteration and recursion]. 2. a function that takes in 2 sorted linked lists, and merges them into a single sorted list. note: This must be done in-place, and it must run in O(n+m).arrow_forwardWrite python code 1) Write a function verifsort that accepts a list as a parameter, check if the list elements are sorted and returns: 1 - if the list is sorted in ascending order, 2 – if the list is sorted in descending order, and 0 – if the list is not sorted.arrow_forwardWe have a list. For example [2,4,6,6,8,2,12,54,15]. Without repeating the elements in the list a new list that does not repeat its elements by creating and using the function that writes Create.arrow_forward
- Write a function REMOVE-NUM that takes a list and returns a list consisting of the original list with all numeric atoms removed. Examples: (REMOVE-NUM '(2 A 6 B 1 C 7 D)) returns the list (A B C D) (REMOVE-NUM '(3 A 4 B (1 E) 7 D)) returns the list (A B (E) D)arrow_forwardGiven a list of integers, implement a function that returns a list of all the subsets of the input list, where each subset is represented as a list of integers.arrow_forwardWrite a Python Code for the given function and conditions: Given function: def insert(self, newElement) Pre-condition: None. Post-condition: This method inserts newElement at the tail of the list. If an element with the same key as newElement already exists in the list, then it concludes the key already exists and does not insert the key.arrow_forward
- Write a function that takes a nested list of integers and add up the elements from all of the nested lists.arrow_forwardImplements clone which duplicates a list. Pay attention, because if there are sublists, they must be duplicated as well. Understand the implementation of the following function, which recursively displays the ids of each node in a list Develop your solution as follows: First copy the nodes of the current list (self) Create a new list with the copied nodes Loop through the nodes of the new list checking the value field If this field is also a list (use isinstance as in the show_ids function) then it calls clone on that list and substitutes the value. Complete the code: def L4(*args,**kwargs): class L4_class(L): def clone(self): def clone_node(node): return <... YOUR CODE HERE ...> r = <... YOUR CODE HERE...> return r return L4_class(*args,**kwargs)arrow_forwardWrite a function merge that merges two lists into one, alternating elements from each list until the end of one of the lists has been reached, then appending the remaining elements of the other list. For example, merging the lists containing A B C and D E F G H should yield the list A D B E C F G H. c++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Introduction to Linked List; Author: Neso Academy;https://www.youtube.com/watch?v=R9PTBwOzceo;License: Standard YouTube License, CC-BY
Linked list | Single, Double & Circular | Data Structures | Lec-23 | Bhanu Priya; Author: Education 4u;https://www.youtube.com/watch?v=IiL_wwFIuaA;License: Standard Youtube License