Create a list of 20 random grades between 0 and 100. Write the code for filtering that generates a list of grades that are A or B only (80<= grades <<100). Use filtering and lambda to create the auxiliary function. Example: [95, 19, 96, 69, 61, 72, 57, 85, 56, 75, 53, 23, 33, 94, 39, 96, 48, 49, 54, 90] Output: [95, 96, 85, 94, 96, 90] Make sure you generate random as required numbers. Don't take input
Q: Write a function named `freq(l)` that takes a list `l` of numbers and returns a tuple of the most…
A: Here is the python3 code implementation of above problem. For input1:…
Q: Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user,…
A: ALGORITHM:- Sort_TAM (TAMUK[]) start = 0, mid = 0, end = length(TAMUK) - 1 while mid <= end if…
Q: Write a function char_counts(string) that takes a string as a parameter and returns a dictionary in…
A: Solution a) We have to use a dictionary as a parameter to take input from the user and then find the…
Q: Write a function find_plateaus that receives a list of integers as parameters. Your function should…
A: A Python program is as follows, File name: “main.py” #Define a function that find and return a list…
Q: Write the function selection_sort_descend_trace() that takes an integer list and sorts the list into…
A: Code of the given program-
Q: consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user,…
A: ALGORITHM:- 1. Make a character or string array out of the string. 2. Compare the letters; if the…
Q: Use Standard ML Code: Write a function that returns the factorial of a number. Write a function…
A: The above question is solved in step 2:-
Q: Write a function called is_factor() that takes as input (x), an object. is_factor (x) outputs TRUE…
A: I have provided the answer based on R studio Programming. Detailed comments are included for a…
Q: Given a singly linked list and a number k, write a function to find the (n/k)-th element, where n is…
A: Code: #include <iostream>#include<math.h>using namespace std; struct node{ int data;…
Q: Write a function count_repeated that takes two lists as a parameters and prints out the number of…
A: I give the code in Python along with output and code screenshot
Q: Write a function print matching_indexes (items, target) that prints the indexes of all the…
A: The range(start, end, interval) function takes three input arguments. The range function returns the…
Q: Write the nondestructive function insertRowCol(L, row, col, val) which takes a rectangular 2D list L…
A: Program Plan: Function insertRowCol has 4 parameters: arr - input arrayr - Row to insert the valuec…
Q: Write a function littler_indices (integers, upper_limit) that returns a list of the indexes of every…
A: def littler_indices(integers, upper_limit): i_list = [] for i in range(0, len(integers)):…
Q: Write a function that will accept a list of numbers and an integer (n). The function should return a…
A: def countByN(myList,n): lis = [] for i in range(len(myList)): if(i%n==0):…
Q: in c++, use parallel arrays , and srand(time(NULL)) to randomize the two cards dealt at the start…
A: The answer for the above question is as follows
Q: In C++ Consider an array of size n. Write a function that takes n values as input for the array,…
A: C++ code: #include <iostream> using namespace std; //function to swap adjacent elements void…
Q: Suppose, you are given a doubly linked list of student marks. Write down a function that checks…
A: #include<iostream> using namespace std; struct node{ double marks; node *next;…
Q: • Add a function that will convert from Fahrenheit to Celsius; • Add a function showMenu () that…
A: Given C++ program should contain 5 functions namely…
Q: Write the function selection_sort_descend_trace() that takes an integer list and sorts the list into…
A: In the given code, we need to implement the concept of selection sort. This sorting algorithm is…
Q: Write a function called `filler(A, 1) that takes an integer A, and a list of integers 1 and if some…
A: so the function in python is:- def filler(A,l,summ=None): if len(l)==0: if…
Q: Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user,…
A: ALGORITHM:- Sort_TAM (TAMUK[]) start = 0, mid = 0, end = length(TAMUK) - 1 while mid <= end if…
Q: Implement the following function without using any additional data structure, and without sorting…
A: ANSWER:-
Q: Write a function sort_and_return_in_pairs_list for example: [12, 13, 11, 15] return =>(11.12) and…
A: Write a function sort_and_return_in_pairs_list for example:[12, 13, 11, 15] return =>(11.12) and…
Q: first is a word-index pair and the second is a word-index This function generates a new word-index…
A: It is defined as a “chunk” of code that you can use over and over again, rather than writing it out…
Q: Implement the following function, without using any data structure. /* Given two vectors of chars,…
A: / include headers #include <bits/stdc++.h> // deinfe the namespace using namespace std; //…
Q: the below function, viral-growth in Racket, so that it can be passed to the below repeated function…
A: It is defined as general purpose programming language. It consists of definitions and expressions,…
Q: works for the selection sort. I need a function that would work using the same logic for the…
A: solution in below step
Q: Python, A. Write a function that accepts a list of integers as an argument and prints the list's…
A: Answer:
Q: The symmetric difference of two lists a and b is the list c having the elements that are not shared…
A: Assuming this is python program. I have checked the code and it is working perfectly.
Q: consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user,…
A: A string made up of the letters A, M, and T is provided to us. We must sort that string using the…
Q: The function list_combination takes two lists as arguments, list_one and list_two. Return from the…
A: Python is a very famous programming language these days, It is an Object oriented programming, which…
Q: Write a function called mutate_list() that takes a 2D-list of integers as the input parameter and…
A: Algorithm Step1: take the for loop for the list and check the size of the 1st list Step2: if the…
Q: Write the following function to sort a list of points on their y-coordinates. Each point is a list…
A: Code def sort(a): n = len(a) for i in range(n): for j in range(n-1): if…
Q: Let's assume a list A that contains non-repeating and unsorted list of numbers. A number A[i] is…
A:
Q: Study the defnition of function funArray and answer the question below. void funArray (double…
A: Solution s=0 and m=2 in function i=0 x[0] = x[0] + x[2] => x[0] = 1+5 = 6 I++ i=1 1<2 true…
Q: Write a function in c programming language that gets an array of points ( function is defined as :…
A: qsort function is defined in stdlib header file. We have to pass the array the length of array the…
Q: Write a function named countUnique that returns the number of unique values in a sorted array. Since…
A: Program plan: Iterate over the array elements to get the length. Define the first element as the…
Q: function biggest_gap(L) that takes a list L of real numbers
A: Approach As language is not mentioned, the function is written in javascript since two values are…
Q: Our second pattern is the mapped list pattern, described in video 4 3 mapped list pattern. Often we…
A: The for loop in Python is used to iterate the statements or a part of the program several times. The…
Q: Write a function sum67 that takes a list as an input parameter and returns the sum of the numbers in…
A: Below is the code in python and sample output:
Q: Suppose you have two objects of Doubly Linked List D1 and D2. Each object is representing a…
A: A linked list is a linear data structure that consists of nodes. A node has a pointer link that…
Q: Consider the following function that takes reference to head of a Doubly Linked List as parameter.…
A: A doubly linked list is a linked list in which it contains two pointers such as a pointer to the…
Q: The symmetric difference of two lists a and b is the list c having the elements that are not shared…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and OUTPUT…
Q: Write a function that sums all the elements of a list that are divisible by 9. What is the result of…
A: Here is the code to sum the numbers of a list divisible by 9 is given as below: The code is divided…
Q: a) Suppose we are trying to hide a secret message by embedding it in random extra letters. Write a…
A: Below is the code in python as language not specified and sample output:
Q: python wirte a function max_indexes(xs) that inserts a list xs with numbers and returns a list of…
A: PROGRAM: #Defining max_indexes() def max_indexes(xs): #Defining list to store the…
Q: Write a function called `filler(A, l)` that takes an integer `A`, and a list of integers `l` and…
A: Code: #import combinations from itertools from itertools import combinations #function called filler…
Q: def f(x,v): return -x**3+5*x**2-8*x+4-(v**2)*(2-x) Define v_list = np.linspace(0, 0.5, 6)…
A: Given program def f(x,v): return -x**3+5*x**2-8*x+4-(v**2)*(2-x) v_list = np.linspace(0, 0.5,…
Create a list of 20 random grades between 0 and 100. Write the code for filtering that generates a list of grades that are A or B only (80<= grades <<100).
Use filtering and lambda to create the auxiliary function.
Example: [95, 19, 96, 69, 61, 72, 57, 85, 56, 75, 53, 23, 33, 94, 39, 96, 48, 49, 54, 90]
Output:
[95, 96, 85, 94, 96, 90]
Make sure you generate random as required numbers. Don't take input
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Complete the below function which takes the coefficients of a polynomial P(x) as a tuple, and a list of values, and returns a list of computed values of P(x). Note that P() can be of any order. For example, P((2,-1,1), [1,2,3]) shall compute P(x) for x=1,2,3P(x)=2x^2 -x +1where x^2 denotes the square of x. Hence, the function must return [2,7,16], because P(1) is 2, P(2) is 7, and P(3) is 16.Write a function biggest_gap(L) that takes a list L of real numbers or integers and finds the largest difference |a−b| between two adjacent elements a and b. The function should return |a−b| and the index of the second element in the list. As an example, a correctly written biggest_gap should return 25,2 when run on L=[7, 13, 38, 43, 53]. Test your function on the array A and show the result. A = [12, 45, 23, 22, 42, 15, 17, 15, 73, 36, 7, 13, 38, 43, 53, 86, 40, 45, 63, 74]Using the function provided, write a function that decides whether two lists are "identical". That is, if cycling by any number N makes the lists identical, the function should return True, otherwise, it should return False. for example identical([1,2,3,4,5], [5,4,1,2,3,]) should give True and identical([1,2,3,4,5,6], [1,2,3,5,4]) should give False.
- Write a function inde which returns the index (start from 1) of the occurrence of a given value. Use helper function. Two functions are enough.inde(1, [1,2,1,1,2,2,1]) → [1,3,4,7] Write a function nele which repeats each element in a list n times. Use helper function. Two functions only.nele([1,2],3) → [1,1,1,2,2,2] Write a function isfact to determine if a positive integer is a factorial number. Do not use any formula such as T(n)=n(n+1)/2. Do it in recursive fashion. Two functions are enough.isfact(120) → trueGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ "((()))", "(()())", "(())()", "()(())", "()()()" ] """ def generate_parenthesis_v1(n): defadd_pair(res, s, left, right): ifleft==0andright==0: res.append(s) return ifright>0: add_pair(res, s+")", left, right-1) ifleft>0: add_pair(res, s+"(", left-1, right+1) res= [] add_pair(res, "", n, 0) returnres def generate_parenthesis_v2(n): defadd_pair(res, s, left, right): ifleft==0andright==0: res.append(s) ifleft>0: add_pair(res, s+"(", left-1, right) ifright>0andleft<right: add_pair(res, s+")", left, right-1).I have this function that works for the selection sort. I need a function that would work using the same logic for the BubbleSort and InsertionSort. void Selection_Sort(struct studentTag STUDENTS[], int nStudents){ struct studentTag s, t, temp; int i, j; for(i = 0; i < nStudents; i++) { for(j = i + 1; j < nStudents; j++) { s = STUDENTS[i]; t = STUDENTS[j]; if (strcmp(s.name.last, t.name.last) > 0) { temp = STUDENTS[j]; STUDENTS[j] = STUDENTS[i]; STUDENTS[i] = temp; } else if (strcmp(s.name.last, t.name.last) == 0) { if (strcmp(s.name.first, t.name.first) > 0) { temp = STUDENTS[j]; STUDENTS[j] = STUDENTS[i]; STUDENTS[i] = temp; } } } } }
- Write a function that gets a linked list of ints, and reverses it. For example - on input 1 -> 2 -> 3 -> 4, after the function finishes the execution, the list becomes 4 -> 3 -> 2 -> 1 - If the list has one element, then it doesn’t change - If the list is empty, then it doesn’t change You may use the data fields in the struct and the functions provided in LL.h and LL.c. // reverses a linked list void LL_reverse(LL_t* list); Test for the Function: void test_q3() { LL_t* lst = LLcreate(); LL_add_to_tail(lst, 1); LL_add_to_tail(lst, 3); LL_add_to_tail(lst, 8); LL_add_to_tail(lst, 4); LL_add_to_tail(lst, 3); LL_reverse(lst); intcorrect[] = {3,4,8,3,1}; inti; node_t* n = lst->head; for(i=0;i<5;i++) { if (n==NULL) { printf("Q3 ERROR: node %d==NULL unexpected\n", i); return; } if (n->data != correct[i]) { printf("Q3 ERROR: node%d->data==%d, expected %d\n", i, n->data, correct[i]); return; } n = n->next; } if (n==NULL) printf("Q3 ok\n"); } Support…Write a function that gets a linked list of ints, and reverses it. For example - on input 1 -> 2 -> 3 -> 4, after the function finishes the execution, the list becomes 4 -> 3 -> 2 -> 1 - If the list has one element, then it doesn’t change - If the list is empty, then it doesn’t change You may use the data fields in the struct and the functions provided in LL.h and LL.c. // reverses a linked list void LL_reverse(LL_t* list); Test for the Function; void test_q3() { LL_t* lst = LLcreate(); LL_add_to_tail(lst, 1); LL_add_to_tail(lst, 3); LL_add_to_tail(lst, 8); LL_add_to_tail(lst, 4); LL_add_to_tail(lst, 3); LL_reverse(lst); intcorrect[] = {3,4,8,3,1}; inti; node_t* n = lst->head; for(i=0;i<5;i++) { if (n==NULL) { printf("Q3 ERROR: node %d==NULL unexpected\n", i); return; } if (n->data != correct[i]) { printf("Q3 ERROR: node%d->data==%d, expected %d\n", i, n->data, correct[i]); return; } n = n->next; } if (n==NULL) printf("Q3 ok\n"); } Support File…Write a function sort_and_return_in_pairs_list for example:[12, 13, 11, 15] return =>(11.12) and (12,13)[14,19,16,18,17,15] return =>(14.15) (16.17) (18.19)
- Write a program that gets a list of integers from input, and outputs the integers in ascending order (lowest to highest). The first integer indicates how many numbers are in the list. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 10 4 39 12 2 the output is: 2 4 10 12 39 For coding simplicity, follow every output value by a space, including the last one. Your program must define and call the following function. When the SortVector function is complete, the vector passed in as the parameter should be sorted.void SortVector(vector<int>& myVec) #include <iostream>#include <vector>using namespace std; /* Define your function here */ int main() {/* Type your code here */ return 0;} Please help me with this problem using c++.Write a program that gets a list of integers from input, and outputs the integers in ascending order (lowest to highest). The first integer indicates how many numbers are in the list. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 10 4 39 12 2 the output is: 2 4 10 12 39 For coding simplicity, follow every output value by a space, including the last one. Your program must define and call the following function. When the SortVector function is complete, the vector passed in as the parameter should be sorted.void SortVector(vector<int>& myVec) Hint: There are many ways to sort a vector. You are welcome to look up and use any existing algorithm. Some believe the simplest to code is bubble sort: https://en.wikipedia.org/wiki/Bubble_sort. But you are welcome to try others: https://en.wikipedia.org/wiki/Sorting_algorithm. #include <iostream>#include <vector>using namespace std; /* Define your function here */ int main() { /*…list_n_perfect_squares This function takes a positive integer, n, and returns a list containing n perfect square numbers, starting with 1 and counting up to n2 Use a list comprehension and a range! Sample runs should look like: >>> list_n_perfect_squares(6)[1, 4, 9, 16, 25, 36]>>> list_n_perfect_squares(1)[1]>>> list_n_perfect_squares(20)[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]