Write a function that takes in 2 lists and checks whether they have the same elements in the same order. If the elements are all the same, the function should return the string “same”. If any of the elements are different, the function should return the string “different”. The definition of the function should be: Def equals(a, b):
Q: print_smallest_and_largest_even Write a function named (numbers_list) that takes a list of numbers…
A: Finding smallest and largest Even number from list using python
Q: Define a function called list_split_and_reverse(a_list) that takes a list as input. If the list is…
A: def list_split_and_reverse(a_list): if len(a_list)==0:#if list is empty print("List is…
Q: 11.16 LAB: Reverse a string Write a recursive function called ReverseString() that takes in a string…
A: Answer
Q: 3. Write a function that takes in a list returns a new list with only the odd elements from the…
A: Note: we are only allowed to solve one question in one post.Since 1 and 2 are done I am solving the…
Q: 17: recursion.cpp) Write two recursive integer functions. The first function should calculate…
A: Introduction of the Program: The C++ program takes the number from the user as input and displays…
Q: 6. Write a program that creates a list-returned function to display a lists contains all but the…
A: The program is written in Python. Check the program screenshot for the indentation. Please check…
Q: numPairs Write a function numPairs that accepts two arguments, a target number and a list of…
A: Actually, python is a easiest programming language. It has a concise(less) code.
Q: Question Enumerate() function / break / loop-else In python, when apply relational operators (e.g.,…
A: Python Code:#Declare two lists...x = [1, 5, 3]y = [1, 6] #Find the length of both the lists...len_x…
Q: C++ 1.Write the function with function header void processList (int list [], int newList[], int…
A: #include <iostream> using namespace std; /*Define a function that receives as arguments two…
Q: o Write a function called average(list) that takes a list as a parameter and returns the average.…
A: ALGORITHM:- 1. Declare and initialise the list with the elements. 2. Pass it to the average()…
Q: Problem 5-Write a function that get a list of numbers as input and checks to see if it is a set or…
A: The code implementation is given below. Algorithm: Prompt the user to enter the number of elements…
Q: Question 3. Write a function called simulate_several_key_strikes . It should take one argument: an…
A: “Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: Exercise 1 Write a function "finalGrade" that takes a list "classList" which contains a sublist for…
A: Input to the Code : The list of student's data Output of the Code : The average of student's data
Q: Write a function truecount in SML of type bool ist -> int that takes a list of boolean values and…
A: We need to write a function truecount in SML of type bool ist -> int that takes a list of boolean…
Q: Q3. Write a recursive function which compares two strings lexicographically, without using any…
A: Please find the answer below :
Q: Description Write the code for the function find_sub which takes as parameter a list input_list and…
A: Q: Find maximum sum sublist
Q: A a. A Pythagorean triple is a list [a, b, c] of positive integers a < b <c so that a + b? = c2.…
A: Python used to answer this question
Q: Description Write the code for the function find_sub which takes as parameter a list input_list and…
A: Here is the required Python code. main.py def read_list(param): p = param.replace(',', '')…
Q: 6. Write and test a function shuffle(myList) that scrambles a list into a random order, like…
A: The answer is given below.
Q: Problem 6 (TOP 3) Write a function called top3(d) that takes a dictionary as its single input…
A: def top3(d): sort_d = sorted(d.items(), key=lambda x: x[1], reverse=True) ans=[] count=0…
Q: Write the following F# functions. You may introduce additional functions if desired. You may not use…
A: multiple subparts are then we can answer only first question at a time if you want answer of…
Q: Presentation exercise 2 Write a function (including docstring) called multiply_term that takes a…
A: Code: def multiply_term( dict1, dict2 ): # to store result in final dictonary merge_dict = {} for…
Q: (1) Define function second that receives a list and returns the second element, in the following…
A: Problem statement: a) use !! infix operator b) use head and tail function See below steps for…
Q: 5. Write a curried version of your function from problem 4. In this part, you will curry the inner…
A: Currying functions: Currying help's in transforming the function, it didn't call a function. It is…
Q: Q2. Write a function named print_big_enough that accepts two parameters, a list of numbers and a…
A: #Function that accepts a list of numbers and a number def print_big_enough(lst1, snum):…
Q: 15- Write a function that takes two positive integers as a parameter .The first integer is the…
A: Provided below is the program which takes two positive integers from user for number of heads and…
Q: The two-dimensional lists m1 and m2 are strictly identical if their corresponding elements are…
A: Program Approach: Create a boolean function which takes two matrices.Using for loop check whether…
Q: 16-Write a function called find_integer_with_most_divisors that receives a list of integers and…
A: Since the programming language is not specified in the question, so I am using python programming…
Q: 2. Write a function which will take list as a argument and this function will return a reversed list…
A: Given :- Write a function which will take list as a argument and this function will return a…
Q: Create a function called get_missing_letters that prompts the user for two English words, and…
A: I have given function to find which alphabet are in neither of two words in python.
Q: Introduction In this lab, you are writing a function slashes_to_written(date_list) that gets the…
A: def slashes_to_written(date_list): month_names = { 1: "January", 2: "February", 3: "March", 4:…
Q: Given a list of lists, for each list stored in main_list, output its contents as follows:…
A: def print_categories(main_list): # main list is empty if not main_list: print("There…
Q: 6.27 LAB: Multiples of ten in a list Write a program that reads a list of integers, and outputs…
A: def is_list_mult10(my_list): count = 0 n = len(my_list) for i in range(0, n): if…
Q: Find the Median without the High and Low Write a function MedianWithoutHL(ScoreList) that takes an…
A: The required Python code is given below: def MedianWithoutHL(ScoreList): # method to takes an…
Q: 1. A list of numbers is said to be balanced if the sum of its first half is equal to the sum of its…
A: As per our company guidelines we are supposed to answer only one question per post and kindly…
Q: 4. Write a function remove_repetition that takes any list 1st and returns a new list with the same…
A: (1) Create an empty list called "res" (2)Loop through each element in the list (3) If the element is…
Q: In SML, combine the two separate code and rewrite into a single function named union that returns…
A: If you assume that a function union: ''a list * ''a list -> ''a list takes two lists of elements…
Q: const std::vector more_words { "this is a sentence.", "this is also words "another line in one",…
A: Standard Template Library(STL): Algorithms The header <algorithm> defines a collection of…
Q: Write a function definition named first_and_second that takes in sequence and returns the first and…
A: python function to find first and second element in the list
Q: Write a function maxGroup that determines, for a given integer list, the stored number of the…
A: l=list(map(int,input().split()))d={}for i in l: if i in d: d[i]+=1; else:…
Q: 4.1 Excercise # 1 Write a function def reverse(string) that computes the reverse of a string. For…
A: def reverse(st): ans="" #for storing reverse of string for i in range(len(st)): ans…
Q: 22.3 LAB: Remove all even numbers from a list Write the remove_evens() function, which receives a…
A: Remove the even numbers of the given list of array. [1,2,3,4,5,6,7,8,9]
Q: Write a program that reads a list of integers, and outputs whether the list contains all multiples…
A: Python program for above : # function to check if list has all multiple of 10 def…
Q: Use the function design recipe to develop a function named unique_list. The function takes a list of…
A: Note : Since the coding language is not mentioned, I have done the code in Python. Algorithm : Step…
Q: Write a function val nextpascalrow : int list -> int list = that given a list of integers that…
A: Given: Write a function val nextpascalrow : int list -> int list = <fun> that given a list…
Q: Presentation exercise 2 Write a function (including docstring) called multiply_term that takes a…
A:
Q: Write a function called chop that takes a list, modifies it by removing the first and last elements,…
A: We will be seeing the simple program for implementing our classes. We will be having comments which…
Q: 2 Pascal triangle Write a function val nextpascalrow : int list -> int list - that given a list of…
A: Pascal’s triangle may be a triangular array of the binomial coefficients. Write a operate that takes…
Q: An acronym is a word formed from the initial letters of words in a set phrase. Define a function…
A: Iterate over the given string character by character. The first character and the upper case…
18) Write a function that takes in 2 lists and checks whether they have the same elements in the same order. If the elements are all the same, the function should return the string “same”. If any of the elements are different, the function should return the string “different”. The definition of the function should be:
Def equals(a, b):
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- 1. Write a function called chop that takes a list, modifies it by removing the first and last elements, and returns None. For example: >>> t = [1, 2, 3, 4, 5, 6] >>> chop(t) >>> t [2, 3, 4, 5] 2. Write a function called list_median that takes a list and returns a new list. If the list has even numbers of elements, the new list will have two elements. If the list has odd numbers of elements, the new list will include only one element. For example: >>> t1 = [5, 1, 2, 3, 4] >>> list_median(t1) [3] >>> t2 = [8, 3, 10, 6] >>> list_median(t2) [6, 8] 3. Write a function called has_duplicates that takes a list and returns True if there is any element that appears more than once. It should not modify the original list. For example: >>> t1 = [5, 1, 2, 3, 4] >>> has_duplicates(t1) False >>> t2 = [5, 1, 2, 3, 2, 8, 10] >>> has_duplicates(t2) TrueC++ I'm interested in knowing if there are two adjacent strings in a list that are very similar to each other. For instance, "Zach" and "Zack" are only one character apart. Write a function, named "CloseEnough" that takes a const reference to a vector of strings and an int. The vector is a list of strings (each of the same length). The int represents how many characters can be different between any two strings next to each other. This function should return the index (an int) of the string that is within the second arguments distance to the next string in the vector. If no index fulfills this criteria, it should return -1. You should be using the STL algorithms to achieve this and no while or for loops.complete the following function. // It is the same as observeCounter except that f has a parameter of type List[Counter] not Counter. // f will insist that the List[Counter] has length 3. // You must return a List[Int] not an Int. // The first element of the result List[Int] must correspond to the number of times that increment/decrement were called on the first element of type List[Counter], similarly for the second and third elements. def observeCounterList (f : List[Counter] => Unit) : List[Int] = { // TODO: Provide definition here. List (-1, -1, -1) }
- Find the Median without the High and Low Write a function MedianWithoutHL(ScoreList) that takes an unsorted list of n numbers as a parameter, discards the highest and the lowest numbers and return the median. You can assume the number of items in the list is between 0.0 and 9.9. To find the median from a list of items, you have tosort the list and find out the value of the item in the middle.Note: If the list has an odd number of items, the median is the value of the middle item. If the list has an even number of items, the median is the average of the two middle items.Exercise, maxCylinderVolume F# system function such as min or methods in the list module such as List.map are not allowed Write a function maxCylinderVolume that takes a list of floating-point tuples that represent dimensions of a cylinder and returns the volume of the cylinder that has the largest volume. Each tuple has two floating point values that are both greater than zero. The first value is the radius r and the second value is the height h. The volume of the cylinder is computed using ??2h. The value π is represented in F# with System.Math.PI. If the list is empty, return 0.0. Examples: > maxCylinderVolume [(2.1, 3.4); (4.7, 2.8); (0.9, 6.1); (3.2, 5.4)];;val it : float = 194.3137888> maxCylinderVolume [(0.33, 0.66)];;val it : float = 0.2257988304PLZ write in SML language. Thank you Write a function maxGroup that determines, for a given integer list, the stored number of the longest consecutive group of equal numbers. For example, maxGroup [2, 9, 8, 8, 8, 7, 9, 1] should return 8 since there are three consecutive 8s in the list. Hint: Solve the problem in two steps. First, determine the length of each group of equal numbers. Then, determine which is the largest.
- emacs/lisp function Write a function that takes one parameter that is a list of numbers and returns true (t) if all the elements of the list are multiples of the first one and nil otherwise. This said, a list generated by the function make-multiples could be passed to this new function and the result should be true. On the other hand, show an example of a list that could not have been generated by the first function for which the result is still true.6.34 LAB: Contact list C++ A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Ex: If the input is: 3 Joe 123-5432 Linda 983-4123 Frank 867-5309 Frank the output is: 867-5309 Your program must define and call the following function. The return value of GetPhoneNumber is the phone number associated with the specific contact name.string GetPhoneNumber(vector<string> nameVec, vector<string> phoneNumberVec, string contactName) Hint: Use two vectors: One for the string names, and the other for the string phone numbers.Q1:Write a function that returns a new list by eliminating theduplicate values in the list. Use the following function header:def eliminateDuplicates(lst):Write a test program that reads in a list of integers, invokes the function,and displays the result. Here is the sample run of the program Enter ten numbers: 2 3 2 1 6 3 4 5 2The distinct numbers are: 1 2 3 6 4 5 Q2:Write a program that reads in your Q1 Pythonsource code file and counts the occurrence of each keyword in the file.Your program should prompt the user to enter the Python source code filename. This is the Q1: code: def eliminateDuplictes(lst):newlist = [] search = set() for i in lst: if i not in search: newlist.append(i) search.add(i) return newlist a=[] n= int(input("Enter the Size of the list:")) for x in range(n):item=input("\nEnter element " + str(x+1) + ":") a.append(item) result = eliminateDuplictes(a) print('\nThe distinct numbers are: ',"%s" % (' '.join(result)))
- def print_categories(main_list): for i in all_categories: main_list = all_categories.split() print(i,":",all_categories[i]) return "" """ 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.10.20 LAB: Multiples of ten in a list Write a program that reads a list of integers, and outputs whether the list contains all multiples of 10, no multiples of 10, or mixed values. Define a function named is_list_mult10 that takes a list as a parameter, and returns a boolean that represents whether the list contains all multiples of ten. Define a function named is_list_no_mult10 that takes a list as a parameter and returns a boolean that represents whether the list contains no multiples of ten. Then, write a main program that takes an integer, representing the size of the list, followed by the list values. The first integer is not in the list. Ex: If the input is: 5 20 40 60 80 100 the output is: all multiples of 10 Ex: If the input is: 5 11 -32 53 -74 95 the output is: no multiples of 10 Ex: If the input is: 5 10 25 30 40 55 the output is: mixed values The program must define and call the following two functions. is_list_mult10() returns true if all integers in the list are…Please do this in C++. The only parts needed are commented as //TODO in MAIN. Please do not use cout, the PrintNodeData in MileageTrackerNode.cpp needs to be called. I am struggling with adding data into the linked list. Given the MileageTrackerNode class, complete main() to insert nodes into a linked list (using the InsertAfter() function). The first user-input value is the number of nodes in the linked list. Use the PrintNodeData() function to print the entire linked list. DO NOT print the dummy head node. Ex. If the input is: 3 2.2 7/2/18 3.2 7/7/18 4.5 7/16/18 the output is: 2.2, 7/2/18 3.2, 7/7/18 4.5, 7/16/18 Main.cpp #include "MileageTrackerNode.h"#include <string>#include <iostream>using namespace std; int main (int argc, char* argv[]) {// References for MileageTrackerNode objectsMileageTrackerNode* headNode;MileageTrackerNode* currNode;MileageTrackerNode* lastNode; double miles;string date;int i; // Front of nodes listheadNode = new…