Question

1.Implement a function which will -       + Accept a number, num, and a list, my_list...

1.Implement a function which will -
      + Accept a number, num, and a list, my_list as arguments
      + return True if num exists in my_list
      + return False otherwise

2. Write Python code to implement the following function -

def find_in_list(item, my_list):
    """
    Look for an item from my_list (of items.)
    If the item is found, return the index position of the item;
    otherwise, return -1.
    """
      #add your code here

3. Given the following list:

      matrix = [[1,2,3],[4,5,6],[7,8,9]]    

Implement logic to extract [7, 5, 3] from matrix.

Homework Answers

Answer #1

/*If you have any query do comment in the comment section else like the solution*/

1.

2.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Implement function reverse that takes a 2D list (a list of list of integers) and returns...
Implement function reverse that takes a 2D list (a list of list of integers) and returns a new 2D list where the items in each row are in reverse order. You maynot use slicing. You may not modify the input list. The returned list should be completely new in memory – no aliases with the input 2D list. From list methods, you may use only the .append(). Examples: reverse([[1,2,3],[4,5,6]])       ->    [[3,2,1],[6,5,4]] reverse([[1,2],[3,4],[5,6]])     ->    [[2,1],[4,3][6,5]] True False In python please
Python Mutable Sequences Implement a function reverse that takes a list as an argument and reverses...
Python Mutable Sequences Implement a function reverse that takes a list as an argument and reverses the list. You should mutate the original list, without creating any new lists. Do NOT return anything. Do not use any built-in list functions such as reverse(). def reverse(lst):    """Reverses lst in place (i.e. doesn't create new lists).     >>> L = [1, 2, 3, 4]     >>> reverse(L)     >>> L     [4, 3, 2, 1]     """
Given the following specifications for an array-based unsorted list, implement all of the functions (declared below)...
Given the following specifications for an array-based unsorted list, implement all of the functions (declared below) and a write a driver code to test all of your implementations. // Define a structure to use as the list item struct ListItem { int key; int Data; }; #define MAX_SIZE 50 // Define maximum length of the list class UnsortedArray { private: int head; // Index to head of the list ListItem theList[MAX_SIZE]; // The list public: UnsortedArray(); // Class constructor ~...
Question2: The following function is supposed to receive a list of numbers and a number as...
Question2: The following function is supposed to receive a list of numbers and a number as the input parameters. The function finds all occurrences of number inside the list and removes them from the list and eventually returns the results. Do you think this function will work as expected? If yes, please mention and if no, please fix it. def function(listOfNumbers, number): for i in range(len(listOfNumbers)): if listOfNumbers[i]==number: listOfNumbers.remove(number) return listOfNumbers newList = function([3,4,1,3,4,7,8,1,2,3,4,6,8], 3) print("After removing the occurrences of...
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings....
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings. You must base your code on the doubly linked list implementation given in my Week 8 slides. Change the code so that instead of an ‘int’ each node stores a string (choose a suitable size). Each node should also have a next node pointer, and previous node pointer. Then write functions to implement the following linked list operations: • A printList function that prints...
convert this code to accept int value instead of float values using python. Make sure to...
convert this code to accept int value instead of float values using python. Make sure to follow the same code. do not change the steps and make sure to point to what code you replaced. make sure to have 2 files Method:----------------------- #define a python user difined method def get_float_val (prompt): is_num = False str_val = input (prompt) #prming read for our while #while is_num == False: (ignore this but it works) old school while not is_num: try: value =...
Python pls create a function called search_position. This function returns a list of 2 tuples and...
Python pls create a function called search_position. This function returns a list of 2 tuples and the number should be start highest number. The first index is the number, and second are list of 2 tuples that sorted by position in alphabetical order: The first index will be position and second index will be champion's name(This also should be sorted by alphabetical order). team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2,...
Part 1: Implement findknn Implement the function findknn, which should find the ?k nearest neighbors of...
Part 1: Implement findknn Implement the function findknn, which should find the ?k nearest neighbors of a set of vectors within a given training data set. The call of: [I,D]=findknn(xTr,xTe,k); should result in two matrices ?I and ?D, both of dimensions ?×?k×n, where ?n is the number of input vectors in xTe. The matrix ?(?,?)I(i,j) is the index of the ??ℎith nearest neighbor of the vector ???(?,:)xTe(j,:). So, for example, if we set i=I(1,3), then xTr(i,:) is the first nearest...
Problem 2: Python 3 Implement a function called gee_whiz that does the following: given argument n,...
Problem 2: Python 3 Implement a function called gee_whiz that does the following: given argument n, a positive integer, it returns a list of n tuples corresponding to the numbers 1 through n (both inclusive): the tuple for the number k consists of k as the first component, and exactly one of the following strings as the second: • the string 'two!' if k is divisible by 2 • the string 'three!' if k is divisible by 3 • the...
Python Problem 1 Create a function, biggest_ip_sum, outside of the ServerClass class, that: 1. Takes two...
Python Problem 1 Create a function, biggest_ip_sum, outside of the ServerClass class, that: 1. Takes two ServerClass objects 2. Sums the octets of the IP together (example 127.0.0.1 = 127+0+0+1 = 128) 3. Returns the larger number Example: server_one = ServerClass("127.0.0.1") server_two = ServerClass("192.168.0.1") result = biggest_ip_sum(server_one, server_two) print(result) In the example above, result will be 361. _________________________________ Problem 1 Here is the code to start with class ServerClass: """ Server class for representing and manipulating servers. """ def __init__(self,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT