please code in python
def duplicate(nums,a):
"""
MODIFIES thelist so that all occurrences of a are duplicated
This function should have NO RETURN STATEMENT
Examples: If a = [1,2,3,1] then a becomes [1,1,2,3,1,1] after duplicate(a,1).
If a = [1,2,3,1] then a remains [1,2,3,1] after duplicate(a,4).
Parameter nums: list to modify
Precondition: nums is a list of ints
Parameter a: value to search for
Precondition: a is an int
"""
# IMPLEMENT A WHILE LOOP HERE
# END WHILE LOOP
pass
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
it gives me the following error, please help me fix it
Testing duplicate assert_equals: expected [5, 3, 3, 3455, 74, 74, 74, 74, 74, 74, 3, 3] but instead got [5, 3, 3, 3455, 74, 74, 74, 74, 74, 3, 3] Line 43 of /Users/fmolukanmi/Documents/cs1110/lab22/tests.py: introcs.assert_equals([5, 3, 3, 3455, 74, 74, 74, 74, 74, 74, 3, 3], mylist) Quitting with Error
it gives me the following error, please help me fix it
Testing duplicate assert_equals: expected [5, 3, 3, 3455, 74, 74, 74, 74, 74, 74, 3, 3] but instead got [5, 3, 3, 3455, 74, 74, 74, 74, 74, 3, 3] Line 43 of /Users/fmolukanmi/Documents/cs1110/lab22/tests.py: introcs.assert_equals([5, 3, 3, 3455, 74, 74, 74, 74, 74, 74, 3, 3], mylist) Quitting with Error
- c++ coding language I need help with part B and C please. If you are unable to do both, then PLEASE prioritize part C. I am really stuck and really can use the help. This is the code for c that was provided in order to guide me: const int N =31; // N parking spaces bool parking[N]; // the garage void EmptyTheLot(bool parking[], int N) { for(int i=0; i<N; i++) p[i]=false; // empty space } // returns -1 if no space found, //otherwise it returns 0<=i<N for a valid space. int FindSpace(int PlateNumber, bool parking[], int N) { // ????? } main() { EmptyTheLot(parking, N); // start with an empty parking garage. // get plate numbers and fill lot. }arrow_forwardC++ languagearrow_forwardProblem DNA: Subsequence markingA common task in dealing with DNA sequences is searching for particular substrings within longer DNA sequences. Write a function mark_dna that takes as parameters a DNA sequence to search, and a shorter target sequence to find within the longer sequence. Have this function return a new altered sequence that is the original sequence with all non-overlapping occurrences of the target surrounded with the characters >> and <<. Hints: ● String slicing is useful for looking at multiple characters at once. ● Remember that you cannot modify the original string directly, you’ll need to build a copy. Start with an empty string and concatenate onto it as you loop. Constraints: ● Don't use the built-in replace string method. All other string methods are permitted. >>> mark_dna('atgcgctagcatg', 'gcg') 'at>>gcg<<ctagcatg' >>> mark_dna('atgcgctagcatg', 'gc')…arrow_forward
- Use stack concepts Q #2 Ô https://www.loc-cs.org/~chu/DataStructu Essay Questions (20% each)- continue [0] [1] [2] [3] myList "Bashful" "Awful" Jumpy "Happy The above "myList" is an ArrayList in Java program. 2. If I want to remove "Awful" from myList, which of the following actions should I take first? a. Move "Happy" to the previous element first. b. Move "Jumpy" to the previous element first. Describe the reason of your choice. Next Pagearrow_forwardJAVA programming languagearrow_forwardC++ The binary search algorithm given in this chapter is nonrecursive. Write and implement a recursive version of the binary search algorithm. The program should prompt Y / y to continue searching and N / n to discontinue. If an item is found in the list display the following message: x found at position y else: x is not in the list Use the following list of integers when testing your program: 2, 6, 8, 13, 25, 33, 39, 42, 53, 58, 61, 68, 71, 84, 97arrow_forward
- Python question Analysis: Invariants (Q16-17) For each of the following functions, identify the loop invariant, exit condition and post condition. Question 16 (Invariant 1) This function returns the list of integers that are multiples of both 3 and 7 that occurs within a given list. Identify the loop exit condition, the loop post-condition, and the loop invariant at the end of the loop, which shows the algorithm’s correctness. def multiples_count(lst): """ Input: a list of integers, lst Output: the list of integers in lst that are multiples of both 3 and 7 """ res = [] for i in range(len(lst)): if lst[i]%3 == 0 and lst[i]%7 == 0: res.append(lst[i]) # Identify the loop invariant here return res Question 17 (Invariant 2) This function checks if a given list (of comparable elements) is sorted in ascending order. Identify the loop exit condition, the loop post-condition, and the loop invariant at the end of each iteration of the loop, which…arrow_forwardPython Big-O Notation/Time Complexity Pls answer only if u know big-o Thanks! Item #3.arrow_forwarddef find_root4(x, epsilon): ''' IN PYTHON Assume: x, epsilon are floating point numbers and epsilon > 0 Use bisection search to find the following root of x such that If x >=0, return y such that x - epsilon <= y ** 2 <= x + epsilon Else, return y such that x - epsilon <= y ** 7 <= x + epsilon Note: You must use bisection search to implement the function. ''' passarrow_forward
- #include <stdio.h>#include <limits.h> int findMissingUtil(int arr[], int low, int high, int diff){ if (high <= low)return INT_MAX; int mid = low + (high - low)/2; if (arr[mid+1] - arr[mid] != diff)return (arr[mid] + diff); if (mid > 0 && arr[mid] - arr[mid-1] != diff)return (arr[mid-1] + diff); if (arr[mid] == arr[0] + mid*diff)return findMissingUtil(arr, mid+1, high, diff); return findMissingUtil(arr, low, mid-1, diff);} int findMissing(int arr[], int n){int diff = (arr[n-1] - arr[0])/n; return findMissingUtil(arr, 0, n-1,diff);} int main(){int arr[] = {120001, 120013, 120025, 120037, 120049, 120061,120085,120097,120109,120121};int n = sizeof(arr)/sizeof(arr[0]);printf("The missing element is %d", findMissing(arr, n));return 0;} ______________________________________________________________________________ Convert the code above into Pseudocodearrow_forwardlanguage = pythonarrow_forward
- 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