2. The following program below returns the maximum of the elements in a list. max ([X|List], Max):- maxlist ([X|List],X,Max).
Q: A contact list is a place where you can store a specific contact with other associated information…
A: Program: # Take the word pair of name & contact separated by commalist_name_num = [i for i in…
Q: Given a list of integers, you required to create a new list such that all the odd index elements…
A: In this problem we will bring all odd index nodes and all even index nodes together and then will…
Q: 2. Write a program that search a letter in a list. Save it as searchLet.py. a) Create a list named…
A: The program is written in python that accomplishes the points mentioned.
Q: We can access the element using subscript directly even if it is somewhere ir between, we cannot do…
A: Here have to determine random access on linked list.
Q: if(l.size() b) I.set(0,b): I.set(l.size()-1, a); Exchanges the elements in the first and the…
A: The given code returns false if list size is less than or equal to 1 else the code stores 1st…
Q: Write a function in Ocaml summax2 : int list -> int = that takes an int list and returns the sum of…
A: (* Write a function max3 of type int * int * int -> int that returns the largest of three…
Q: String makeString(String start, String sep, String end) Returns a string representation of this…
A: import java.util.*;import java.lang.*;import java.io.*; class StringList{ ArrayList<String>…
Q: 7-Write a procedure that returns the list that contains everything except for the last element of…
A: first we have to write scheme code and then run that code on an scheme compiler: As per the example…
Q: Dark_characters = {"Martha":[20,37,51], "Noah":[15,35,41], "Agnes":[9,37,38], "Jonas":[3,26,25],…
A: Given :
Q: The following is useful as part of a program to play Minesweeper. Suppose you have a 5×5 list that…
A: Python program for above : def Count( M_swap , i, j): count = 0 if( i-1 >= 0 and…
Q: Linked list is more suitable data structure than array for a program that requires a lot of…
A: I have given justification for given question why it's true or false.
Q: 1. Write a program that has a loop to read in ten strings and put them into a list. Write a second…
A: Use a for loop to iterate from 0 to 9 in first loop and 9 to 0 in another loop
Q: Indicate true or false for the following statements:(a) Every element in a list must have the same…
A: Note: There are multiple questions are given in one question. According to the rule, you will get…
Q: Following Exercise-2 (Available under Week-5 on moodle), create your list (of 5 elements) and…
A: CODE: # creating an empty list lst = [] # number of elemetns as input n = int(input("Enter number of…
Q: Exercise 4: Write a program that reads n student's test scores in the range 0-100 from an input…
A: Python code for the given problem :- Note :- Indention might be lost in the code while pasting it…
Q: debugg help def print_categories(main_list): if id not in main_list: print("There…
A: Algorithm: Read the list and display the main list. Read the index and check whether the index is…
Q: (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store…
A: EXPLANATION: You are program works correctly. But your issue based on the software. Use Python…
Q: def make_grid (w: int, h: int, player_coord: Tuple lint, int], gold_coord: Tuple[int, int]) -> List…
A: The program is written python l=[]L=[]def make_grid(w,h,player_coord,gold_coord): for i in…
Q: PYTHON 3 def get_graded(infolist): """ param: infolist - a list that contains dictionaries…
A: grades = [] for d in infolist: if d["grades"] != []:…
Q: Exercise 4: Write a program that reads n student’s test scores in the range 0-100 from an input…
A: Python code for the given problem :- Note :- (Indention might be lost after i copy the code here,…
Q: 2. Write a program that search a letter in a list. Save it as searchLet.py. a) Create a list named…
A: Programming instructions: Create a list. Take input from the user. If the user enters only one…
Q: Dictionary Walk Program Using Java, write a program which takes two words as inputs and walks…
A: Since you have posted a question with multiple sub-parts, according to the company's policy we will…
Q: 7. You could create a circular list from a single- linked list by executing the statement. a. tail.…
A: Hey, since multiple questions posted, we will answer first question according to our policy. If you…
Q: please code in python Create a program that takes in a string of words separated by spaces. Create…
A: Solution: Given, Create a program that takes in a string of words separated by spaces. Create a…
Q: read positive numbers from user and create a double linked list. the list should stop expanding the…
A: #include <iostream>using namespace std; struct Node { int data; Node* prev; Node*…
Q: What is the difference between appending a node to a list and inserting a node into a list?
A: GIVEN: What is the difference between appending a node to a list and inserting a node into a list?…
Q: (1)Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store…
A: Program: Your program is perfectly correct. Kindly run your code in…
Q: n a linked list. Please use C
A: given - 1. Write a simple procedure to count the number of elements in a linked list. Please use C
Q: Write a statement that assigns the list of seasons of the year to the variable seasons in the…
A: #1) Write a statement that assigns the list of seasons of the year#to the variable seasons in the…
Q: let's try accessing the value of a list element in a random index position! Let's do this fast!…
A: Code: import java.util.ArrayList;import java.util.Scanner;public class Main{ public static void…
Q: (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store…
A: Program: #create an empty list to store wt wt = [] # (1) #get the four wt from the user for i in…
Q: Exercise 4: Write a program that reads n student's test scores in the range 0-100 from an input…
A: def readData(): # the user define function to…
Q: def get_words(training_text: TextIO) -> List[str]: """Return a new list containing the words from…
A: Code:- from typing import TextIO, List def get_words(training_text: TextIO)->List[str]: result =…
Q: A code segment is intended to transform the list utensils so thất thế last élement öf the list is…
A: Lets see the solution.
Q: Write the following function that returns true if the list is already sorted either in an increasing…
A: Please find the answer below :
Q: 1. Write a program to get the first and last element for the linked list. The Elements are…
A: As per our guidelines we are supposed to answer only one question. Kindly repost other questions as…
Q: A contact list is a place where you can store a specific contact with other associated information…
A: Step-1: Start Step-2: Declare variable pn take input word pairs Step-3: Declare variable search and…
Q: a list, iterate it, and display numbers divisible by five, and if you find a number greater than…
A: list1 = [12, 15, 32, 42, 55, 75, 122, 132, 150, 180, 200]for item in list1: if (item > 150):…
Q: 1. Using the singly-linked list shown below, and assuming that head references the first Node and…
A: Below are the statements to perform the following instruction: -
Q: Write list comprehensions to generate the following: i) If numlist contains a list of numbers,…
A: The PYTHON code is given below with code and output screenshot Happy Coding ?
Q: A list can be an element in another list.True or False
A: The nesting of list feature is called nested list comprehension. Here we can have list like…
Q: Exercise 4: Write a program that reads n student's test scores in the range 0-100 from an input…
A: The python code is given below:
Q: Python write a program in python that plays the game of Hangman. When the user plays Hangman, the…
A: Python Code for word guessing game Hangman
Q: Given a list of integers, you required to create a new list such that all the odd index elements…
A: Here I have created an array with some values in it, and also find out the size of the array. Next,…
Q: A contact list is a place where you can store a specific contact with other associated information…
A: using namespace std; #include <iostream> #include <vector> #include <string>…
Q: Write a python code that rolls 2 dice 10 times and saves them in separate lists. Then, add each roll…
A: Solution: import random import turtle l = []sumAll = 0 print("\nProgram to roll two dices and…
Q: (python) Is the statement true or false? To add an element to the end of a list, use the append…
A: The append function in python
Q: 1. (Display words in descending alphabetical order) Write a program utilizing list implementations…
A: Here is the approach : Create two list of the strings . Take input from the user for both the…
Step by step
Solved in 2 steps
- Create a program that removes duplicate integer values from a list. For example if a list has these valuesList = [5, 7, 8, 10, 8, 5, 12, 15, 12]. After applying the removal function, you should have List = [5, 7, 8,10, 12, 15]. In your case you will get the numbers of list from the user.Given two lists(List1, List2) of INTs create a third list such that should contain only odd numbers from the first list and even numbers from the second list def mergeList(listOne, listTwo): thirdList = [] #complete the functionWrite the following function that sorts and merges two lists into a new sorted list. The new list contains only even numbers. def myMergeEvenList(list1, list2): Enter list1: 10,5,6,7 Enter list2: 12,8,5,0,1 The merged list is: 0,6,8,10,12
- Considering all the elements and its indexes at the right side:Write a sequence of List operations that would result to a LIST that contains ONLY the elements with its respective indexes: {index[00]=104, index[01]=165, index[02]=115, index[03]=384, index[04]=248, index[05]=117}.Write a statement, using pyhton language, that creates a two-dimensional list with 5 rows and 3 columns. Then write nested loops that get an integer value from the user for each element in the list.(1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements with two digits after the decimal point. Hint: Use a conversion specifier to output with a certain number of digits after the decimal point. (3) Output the max list element with two digits after the decimal point.Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] Average weight: 166.95 Max weight: 236.00 (4) Prompt the user for a number between 1 and 4. Output the weight at the user specified location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. Ex: Enter a list location (1 - 4): 3 Weight in pounds: 176.00 Weight in kilograms: 80.00 (5) Sort the list's elements from…
- (1)Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements with two digits after the decimal point. Hint: Use a conversion specifier to output with a certain number of digits after the decimal point. (3) Output the max list element with two digits after the decimal point. Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] Average weight: 166.95 Max weight: 236.00 (4) Prompt the user for a number between 1 and 4. Output the weight at the user specified location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. Ex: Enter a list location (1 - 4): 3 Weight in pounds: 176.00 Weight in kilograms: 80.00 (5) Sort the list's elements from…(1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list.Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements with two digits after the decimal point. Hint: Use a conversion specifier to output with a certain number of digits after the decimal point. (3) Output the max list element with two digits after the decimal point.Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] Average weight: 166.95 Max weight: 236.00 (4) Prompt the user for a number between 1 and 4. Output the weight at the user specified location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. Ex: Enter a list location (1 - 4): 3 Weight in pounds: 176.00 Weight in kilograms: 80.00 (5) Sort the list's elements from least…7-Write a procedure that returns the list that contains everything except for the last element of the given (nonempty) list. For example, (last-element ‘(a (b c ) (d)) ) returns (a (b c)). For example, (last-element ‘(a (b c ) (d) ) ) returns (a (b c)) . Then, Manually trace your procedure with the provided example.
- Please answer quick. In python The FlipList class defined below is intended to be identical to a list, except that the append method only adds new elements to the back of the list when the length of the list is odd. When the length is even, append should instead add the new element to the front of the list. class FlipList(list): def append(self, item): if len(self) % 2 == 0: self.insert(0, item) else: _________ Fill in the blank with a line of code such that FlipList works as described above.) Write list comprehensions to generate the following:i) If numlist contains a list of numbers, create a new list that contains only thosenumbers that are less than 100. (e.g. [42, 130, 7, 100, 101] becomes [42, 7])ii) The numbers from 3 to 30 that are multiples of 3 (i.e. 3, 6, 9, 12, 15... 30)iii) The numbers from 3 to 30 that are multiples of both 3 and 2 (i.e. 6, 12, 18...)iv) If wordlist contains a list of strings, create a new list that has the words that startwith “p” or “P”. (e.g. [“Apple”, “pear”, “avocado”, “Pumpkin”] becomes[“pear”,”Pumpkin”] )C5 write a program that will take an integer value as input and do the following task,- If the value is odd, insert it as 2nd last element- if the value is even, delete the 2nd element from the list