use python to solve this problem
import java.util.*;
class Main {
public static void main(String[] args) {
contains();
}
public static boolean contains(){
ArrayList<String> l= new ArrayList<String>();
l.add("1");
l.add("2");
l.add("3");
l.add("4");
ArrayList<String> s= new ArrayList<String>();
s.add("3");
s.add("7");
s.add("8");
s.add("9");
//Iterating s list and comparing with l list
for (String temp : s){
if(l.contains(temp)){//if the list contain any value equal return
true
System.out.println("true");
return true;
}else{//if the list doesn't contain any value equal return
false
System.out.println("false");
return false;
}
}
return false;
}
}
use python to solve this problem Problem 3- contains.py: Sub-list containment You will write a function...
Python 2.7 Write a function cumsum() that takes a list l as argument and returns the cumulative sum (also known as the prefix sum) of l, which is a list, say cs of the same length as l such that each element cs[i] is equal to the sum of the first i + 1 elements of l, i.e., cs[i] == l[0] + l[1] + l[2] + ... + l[i] You should not modify the argument list l in any way....
use python 2a. Union (1 points) Make a union function which takes in 2 lists as parameters and returns a list. It should return a list that contain all elements that are in either list. Your results list should contain no duplicates. For example, if the two lists are [1,5,6,5, 2] and [3,5, 1,9] then the result list is (1,5,6,2,3,9). Note that the list sizes don't have to be equal. Note that the input lists could have duplicates, but your...
Using PYTHON: (Find the index of the smallest element) Write a function that returns the index of the smallest element in a list of integers. If the number of such elements is greater than 1, return the smallest index. Use the following header: def indexOfSmallestElement(lst): Write a test program that prompts the user to enter a list of numbers, invokes this function to return the index of the smallest element, and displays the index. PLEASE USE LISTS!
Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as described below. Calls the function find_item_in_grid and prints the result. The find_item_in_grid function should have one parameter, which it should assume is a list of lists (a 2D list). The function should ask the user for a row number and a column number. It should return (not print) the item in the 2D list at the row and column specified by the user. The...
solve with python Write a recursive function recStringWithLenCount() that takes a one-dimensional list of strings as a parameter and returns the count of strings that have at least the length of second parameter passed into the function that are found in the list. Recall that you can determine whether an item is a string by writing type(item) == str. The only list functions you are allowed to use are len(), indexing (lst[i] for an integer i), or slicing (lst[i:j] for...
IN PYTHON Develop the program that will allow you to obtain an ordered list of whole numbers from least to greatest from two lists of whole numbers. The individual values of the input lists are captured by the user one by one and then both lists will be joined and then sorted in ascending order (from lowest to highest value). Your program should allow the capture of the entire values of the lists without making use of messages (legends) to...
All of the problems must be done in Haskell. You may download a local IDE or use [this website.][https://repl.it/languages/haskell]. You are not allowed any functions that trivialize a problem! Here are some examples of lists you can test your solutions on: let list1 = [5, 10, 15, 20, 25, 30] let list2 = [50, 100, 150, 200, 250, 300] Write a function that returns the maximum value in a list. Write a function that returns the nth element in the...
The language is python Write the function largest_edge_group(vertices) that consumes vertices, a list of list of integer containing the coordinates of the consecutive vertices of a polygon. The function largest_edge_group returns the size of the largest group of same length edges. Your function must run in O(n), where n is the length of vertices. Example largest_edge_group([[0,0],[1,1],[0,2],[-2,3],[-1,2]]) => 3 Hint Remember, it is not possible to compare Floats for strict equality, but since the coordinates are integers, the squared distance is...
write the following code in python 3.2+. Recursive function prefered. Thank you! Define a function named q3() that accepts a List of characters as a parameter and returns a Dictionary. The Dictionary values will be determined by counting the unique 3 letter combinations created by combining the values at index 0, 1, 2 in the List, then the values at index 1, 2, 3 and so on. The q3() function should continue analyzing each sequential 3 letter combination and using...
i need python code, thank you very much! characters) and prints ) 3. Write function, smallestCharacterLargerThan(keyChar, inputString) that takes as input key character, keyChar, and a string of one or more letters (and no other the "smallest" character in the string that is larger than keyChar, where one character is smaller than another if it occurs earlier in the alphabet (thus 'C is smaller than 'y' and both are larger than 'B') and 2) the index of the final occurrence...