In Python Use the Design Recipe to write a function bools_2_str, which consumes a list of booleans and returns a string of the same length as the list. Where the list has True, the string should have 'X', and where the list has False, the string should have ' ' (i.e., a single space).
Q: Write a Python function that takes a list and returns a new list with the first list's unique…
A: def fun(l): d={} for i in l: if i not in d: d[i]=1 return d.keys()print('Enter space separated…
Q: Write a program in haskell programming language to subtract 10 from all list elements without using…
A: Requirements:- Write a program in Haskell programming language to subtract 10 from all list elements…
Q: Write a python function that takes a list as an argument. Your task is to create a new list where…
A: def remove(lst): lst_1=[] for i in lst: if lst_1.count(i)==2: pass…
Q: Write a function that accepts a variable number of string parameters. The function must use list…
A: Answer in step2
Q: Write a python function that takes a list as an argument. Your task is to create a new list where…
A: Read the size of the list and the list element using map() which takes list input from the user.…
Q: 2. Write a python program as function that displays a list Prog and returns a tuple of two list…
A: def fun(Prog): # user define function print("The list:", Prog) # display the…
Q: PYTHON!!! Implement a function insert_sorted, which will insert a string into its appropriate…
A: Note: list.sort(): if list is of strings then, it will sort them in alphabetical order.
Q: In PYTHON Given a list of ints, a start index, and an end index (not inclusive), function should…
A: Below is the code in python and sample output:
Q: Write a python function that takes a list as an argument. Your task is to create a new list where…
A: A list is a data item that stores many values using a single variable name. To define a list all…
Q: In Python use the Design Recipe to write a function count_evens_NxN, that consumes a nested list…
A: import unittest #function def count_evens_NxN(nested_list): result=0 #Iterating the matrix for i in…
Q: Given a ListItem class, complete main() using the built-in list type to create a linked list called…
A: Program approach: Go to main.cpp declare list. Use a while loop. input item. if the inputted item…
Q: Write a function primeFac in Python that computes the prime factorization of a number: it accepts a…
A: The Python function to get the list of prime factors of a number greater than 1:Also I have checked…
Q: It returns how many times the number is found in the list. If the number is not in the list, return…
A: def how_many(a_list,a_num): count=0 #initializing count is zero for i in…
Q: Solve in Python: A contact list is a place where you can store a specific contact with other…
A: First, we will input the string. Then we will split the string and find the number of person…
Q: It should return a new list consisting of all the numbers in the list that are greater than the…
A: def find_bigger(a_list,a_num): count=[] #initializing empty list for storing…
Q: Write a python program as function that displays a list Prog and returns a tuple of two list…
A: Algorithm: Create function(Prog) Display list prog for i in range(len(Prog)) if %2==0…
Q: In Python Use the Design Recipe to write a function, print_histogram that consumes a list of…
A: Programming Instructions: Define the function print_histogram which takes the list of integers as…
Q: Write a function last_chars, which has a list of strings and an integer num as its input parameters.…
A: Python code to perform the given question is given below.
Q: Write a PYTHON function (program) that takes a list as argument, and returns its first element.
A: Coded using Python 3.
Q: Write a function wordfreg(s) that returns a list of the number of occurences of each word in s. Each…
A: Here I have defined the function named wordfreq(). Inside the function, I have converted the string…
Q: Write a function that accepts two lists as it's only arguments. The function should return a new…
A: PYTHON code for above : # required function for above def func(list1, list2): list3 = list1…
Q: PYTHON!!! Write a function that accepts a required threshold amount (int), and variable number of…
A: def append_string(threshold,val):#here is my python code it will accepts two parametres one is…
Q: Write a function find triplets that (1) is given a list and a target value and (2) returns a list of…
A: def find_triplets(A, target): result = [] arr_size = len(A) for i in range( 0, arr_size-2):…
Q: In Python, ask user to enter a string, e.g., The flower is red, convert it to a list using the…
A: Introduction List: To store several elements in a single variable, use lists. In Python, collections…
Q: Define colorListCircles with 2 parameters Use def to define colorListCircles with 2 parameters The…
A: Python's Turtle module, and he asked to see concentric circles. I thought it would be faster to use…
Q: Write python function that will take list as parameter and will return sum of all elements in the…
A: HI THEREI AM ADDING PYTHON CODE AS PER YOUR REQUIREMENT BELOWPLEASE GO THROUGH IT THANK YOU
Q: In python, create a code that accepts the size of a list as an input (n). It will print out all the…
A: here in this question we have asked to write a python program which take a list of size n as input…
Q: In Python use the Design Recipe to write a function, count_odds, that consumes a list and two…
A: Program Instructions:Write the function header and type contrast of the program.Write description…
Q: Write a function named mostCharacters that takes a list of strings as an argument and a character as…
A: Program: Programs are used to provide the instructions to the system. It is used to solve complex…
Q: Write a python function that takes a list as an argument. Your task is to create a new list where…
A: the given python code is takes list as argument and prints the number of elements removed from the…
Q: In Python Use the Design Recipe to write a function round_list, which consumes two arguments, a list…
A: Program Instructions:Write the function header and type contrast of the program.Write description…
Q: Write a function that accepts a number and a string as arguments. It should return a list having n…
A: We need to write a function that accepts two parameters- a number a string The function will…
Q: Write a recursive Python function named initList to create a list containing the values from 0 to…
A: def initList(L, n): # function to create a list containing the values from 0 to n-1…
Q: how to write a function in python 3 that take a tuple t = (7,8,4,20,11) and returns a list which…
A: Note: The below program has been complied and executed in “repl.it” online complier
Q: Assume that L is a list of Boolean values, True and False. Write a program in python with a function…
A: #function that takes boolean list of values#then returns a tuple which contains start and end of…
Q: Write a recursive function named Multiply2 that multiples by 2 and prints each element in a given…
A: I have given answer in step2
Q: representing the current row of the Pascal triangle, and returns as an output a list representing…
A: 1.ocaml is lightweight Fuctional language 2.Fueled by six basic data types 3.powerful custom data…
Q: Use the Design Recipe to write a function, count_odds, that consumes a list and two integers,…
A: Please find the answer below :
Q: Edsgar Dijkstra is known for his work on programming languages. He came up with a neat problem that…
A: def dutch_flag(color_list):""" (list of str) -> list of strReturn color_list rearranged so that…
Q: Please answer it in Python Write a function min_pair that takes a list as an argument and returns…
A: '''logic to solve this problem:first extract all even numbers to a new list :Nthen traverse each…
Q: Python has the following syntax: In order to print each item in a list, create a function called…
A: Python program to solve the given problem is below.
Q: Write a function removeN which takes three arguments called N, E and L (where L is a list) and…
A: Find the code attached. package com.company;import java.util.*;public class Main { public static…
Q: In PYTHON, write a program that reads elements from a list, where each element from the list is a…
A: logic:- use for each loop to iterate nested loop. for i in numbers: a=i[0] b=i[1]…
Q: Write a program that reads a list of integers, and outputs whether the list contains all multiples…
A: Answer
Q: Write a decale function that takes as an argument a list l and a number d and returns the list…
A: # returns the list obtained from l by adding an offset of d to each element of ldef decale(lst, d):…
Q: this code should be in python: write a function that receives a list as its only parameter. Inside…
A: Introduction: this code should be in python: write a function that receives a list as its only…
Q: Create a function in Python named rare (s) which takes as parameter a integer s, and which returns a…
A: The problem is based on the basics of functions in python programming language.
Q: In Python Use the Design Recipe to write a function has_duplicates, which consumes a list and…
A: This program returns true when a list has duplicate value, if the list has not any duplicate value…
Q: Use def to define colorListCircles with 2 parameters The colorListCircles function must draw…
A: Python's Turtle module, and he asked to see concentric circles. I thought it would be faster to use…
In Python
Use the Design Recipe to write a function bools_2_str, which consumes a list of booleans and returns a string of the same length as the list. Where the list has True, the string should have 'X', and where the list has False, the string should have ' ' (i.e., a single space).
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Code in python Given a list, L, the function front_two creates a new list of length 2 out of the first two items in L as follows: In the new list, the second item becomes the first item, and the first item becomes the second. If L contains only one item, the first item in the new list should be the value None. If L is empty, both items in the new list should be value None. The function returns the new list. For example: Test Result L = ['a', 'b', 'c', 'd'] print(front_two(L)) ['b', 'a'] L = [] print(front_two(L)) [None, None] L = [5, 2] print(front_two(L)) [2, 5] L = [7] print(front_two(L)) [None, 7]The Python function fourthMultLast below should take a list of numbers as input and return the sum of the third element and the last element of the list. For example, if the input list is 1,2,3,4,5,6,7,8,9, the function should return 36 which is the multiply 4 and 9. ############ ###### ##### 1def fourthMultLast (inList): ans = inList[4] 2 3 return ans #####; #### ##### There is an Error on line number 2. Fix the bug. Note: You should only make changes to line number 2. For example: Test inList[-1] ### Only change this line of code fourthMultLast([1,2,3,4,5,6,7,8,9]) 36 2 3 Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30 %) Reset answer 1def fourthMultLast(inList): Precheck Result Check ans = inList[4] * inList[-1] ### Only change this line of code return ans Pwrite a c++ code uisng linked list for quiz. In quiz game, questions are chosen in such a a way that they cover all fields of a typical quiz contest. The user’s general knowledge is tested with quiz questions regarding science, technology, movies, sports, general health, geography and many more. • Edit score• Help-- menu • Show record• Show score• Reset score The game ends when the user’s cash prize piles up to 100RS. For each question there are 4 options A, B, C and D and no negative markings. so money would not be deducted for wrong answersto the questions.
- In Python Use the Design Recipe to write a function has_duplicates, which consumes a list and returns True if the list has any duplicate entries, False otherwise. Your function should return False if the list is emptyIn Python Use the Design Recipe to write a function, print_histogram that consumes a list of numbers and prints a histogram graph using asterisks to represent each number in the list. Use one output line per number in the list. You may assume that only integers are passed to this function. Your function should ignore negative values. Include a docstring!In C++ Write a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pairs (original and replacement) that follow. The next line of input begins with an integer indicating the number of words in the sentence that follows. Any word on the original list is replaced. Ex: If the input is: 3 automobile car manufacturer maker children kids15 The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. then the output is: The car maker recommends car seats for kids if the car doesn't already have one. You can assume the original words are unique. For coding simplicity, follow each output word by a space, even the last one. Hint: For words to replace, use two vectors: One for the original words, and the other for the replacements. Your program must define and call the following function that returns index of word's first occurrence in wordList. If not found, then the function…
- Write a function that accepts a string parameter. The function must use a listcomprehension to build a list of characters. An example of calling the function and printing the value returned by the function would be: print(your_func("this.is,a-test.")) ['.', ',', '-', '.'] DO NOT USE: Dictionaries, Object-Oriented programming, and Python shortcuts!!!PYTHON CODEWrite a function list3Digit10() that creates and returns a list that contain all positive 3-digit numbers that are multiples of 10. The function call list3Digit10() will return a list containing 100, 110, 120, ..., 990.Assume that L is a list of Boolean values, True and False. Write a program in python with a function longestFalse(L) which returns a tuple (start, end) representing the start and end indices of the longest run of False values in L. If there is a tie, then return the first such run. For example, if L is False False True False False False False True True False False 0 1 2 3 4 5 6 7 8 9 10 then the function would return (3, 6), since the longest run of False is from 3 to 6.
- from surround import surround inputs = [] [] answers = L = ["tank", "godzilla", "tank"] ["tank"] inputs.append (L) answers.append(a) a = TESTS len(inputs) passed = 0 for i in range(TESTS): try: result = surround (inputs[i]) if result not in answers[i]: print("Error found for input: " + str(inputs[i])) else: passed += 1 except Exception: pass result = "Tests passed: + str(passed) + "/" + str(TESTS) print(result)In c++ please. Thank you! 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. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use linear search. Modify the algorithm to output the count of how many comparisons were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Joe 123-5432 Linda 983-4123 Frank 867-5309 Frank the output is:…Using 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 A. Create a struct in your program called ContactInfo to store a name and a phone number. B. Define and call the following function. The return value of GetPhoneNumber is the phone number associated with the provided contact name. If the name is not found, the function should return "not found". string GetPhoneNumber(ContactInfo contacts[], int size, string contactName) C. Your main function should declare an array of ContactInfo structs of size…