Use the Design Recipe to write a function weighted_total(number_list,weights) that consumes a list of numbers and a list of weights and returns the weighted total of the numbers. If the numbers are [1,2,3] and the weights are [0.1,0.5,0.4] then the weighted total should be 1 * 0.1 + 2 * 0.5 + 3 * 0.4 = 2.3 Think about what needs to happen before using a loop, during the loop, and after the loop finishes. In this question you are required to use a for loop, and not allowed to use the sum function.
Q: Analyze the given function below that takes a list of numbers with size (n) and returns the number…
A: def function(List): oddCount = 0 # 1 step evenCount = 0 # 1 step…
Q: Write python code 1) Write a function verifsort that accepts a list as a parameter, check if the…
A: The problem is based on the basics of functions in python programming language.
Q: Using foldl, define a function num2int :: [Int] -> Int -> Int that converts a list of numbers and…
A: The most basic thing you could do is check if x=floor(x), Here floor returns the integer part of a…
Q: Write a function isln that accepts two strings as arguments and returns True if either string occurs…
A: Note: AS, per company guidelines we are supposed to answer only one question at a time (as both are…
Q: Write in C Language Description F(x) = x + 1 G(x, y) = x + y Please write a program to…
A: /* C program to calculate the value of composite of F and G */ #include<stdio.h> int F(int x)…
Q: Write a function called find_max that takes a two-dimensional list as a parameter and returns the…
A: program code : // C# program to find row with// max sum in a matrixusing System;using…
Q: Write a c++ program: Write a function named convertToLowestTerms that inputs two integer parameters…
A: Program code: //include required header files #include<iostream> using namespace std;…
Q: Write a function in Python that takes two strings of DNA sequence (say string1 and string2) as input…
A: 1) Below is Program that take two string of DNA sequence and return the list of positions of string2…
Q: Write a function definition which has two parameters, both lists. The function is supposed to return…
A: Here have to determine python code for given problem.
Q: Write one function du(a,b) which returns a list of a b times (b>=0). Must use identical function…
A: Here function defintion is given , du(a,b) So here is the code given below with proper comments:…
Q: Write a function which accepts two sequences of numbers from the user, each number separated by a…
A: Program: #taking string data type input from user and stored in#'sequenceOne' variable for first…
Q: write a function that allows the input of a list of strings as its only parameter. Inside the body…
A: list = []n = int(input("Enter number of words : ")) for i in range(0, n): print("Enter Word -",)…
Q: Suppose you have to design a number calculation system. You need to write a recursive function that…
A: Program Plan: Define the firstFunctionMax() method that find the max element in the 2D list.…
Q: C++ Programming You are given a list of M positive numbers, Ao, A1. ..., AM-1- You have to answer Q…
A: Required: We have to write a code in C++ where we are provided with a list of M positive numbers,…
Q: python code. Instructions are given below for each function. Run function is already done. 1) def…
A: A required program is as follows, Program: def num_to_digit_rec(num, base): """ Return a…
Q: Write a function convert_to_millimetres (measurements) which takes a list of measurements in…
A: def convert_to_millimetres(measurements): for i in range(len(measurements)):…
Q: Write the in_order() function, which has a list of integers as a parameter, and returns True if the…
A: If the list is sorted the element l[i] <= l[i+1] for every index of i in list l.
Q: Write a C program and the name of the function is bigv and the argument declared is size, where size…
A: Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: Write a function convert_to_millimetres (measurements) which takes a list of measurements in…
A: Here I have created a function and inside the function, I have used a for loop to iterate over the…
Q: Suppose you have to design a number calculation system. You need to write a recursive function that…
A: Program Plan: Define the firstFunctionMax() method that find the max element in the 2D list.…
Q: Write a function that takes two parameters, a and b, both are lists of floating-point numbers, and…
A: According to the Question below the Solution: Output:
Q: Write out the call stack for this program if x is 3. function factorial(x) { if (x === 0) { return…
A: Given: Javascript: Write out the call stack for this program if x is 3. function factorial(x) {if…
Q: Write a function get_names(), which prompts the user for a sequence of names, where each name can…
A: Note: Since no programming language is mentioned. I am attempting this in python. if you need it in…
Q: Suppose you have to design a number calculation system. You need to write a recursive function that…
A: Input : List of list Output : Maximum number in the list of list.
Q: 1. Create the functions sadness_score, and happiness_score 2. Each function has only 1 parameter of…
A: Step 1: Define function sadness_score(). Initialize list consisting of words and their weights.…
Q: Computer Science Write a generator function that generates each of the numbers requested in the…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: Using C language, write a program using function that will ask the user to input any set of numbers…
A: Given: Using C language, write a program using function that will ask the user to input any set of…
Q: Please answer it in Python 1) Write a function last_consonant that takes as an argument a word and…
A: as per our policy i have given only one answer question 1.
Q: Suppose you have to design a number calculation system. You need to write a recursive function that…
A: 1. function first a. check if index is out of index of array i. if yes return…
Q: Suppose you have to design a number calculation system. You need to write a recursive function that…
A: According to the information given:- we have to list the minimum number from the list provided.
Q: Use Python)Use the Design Recipe to write a function weighted_total(number_list,weights) that…
A: # if we define numbers and weights arrays/list numbers = [1,2,3]weights = [0.1, 0.5, 0.4] def…
Q: We would like to write a collection of functions that do operations on a list of numbers. For…
A: Actually, python is a easiest programming language. It has a concise(less) code.
Q: Using the function provided, write a function that decides whether two lists are "identical". That…
A: Step 1: Define the function identical() which takes two lists as arguments. Step 2: Check whether…
Q: Use the function design recipe to develop a function named Fibonacci_sequence. The function takes an…
A: def Fibonacci_sequence(n): n1 = 0 n2 = 1 total = 0 count_nums = 1 result = []…
Q: Suppose you have to design a number calculation system. You need to write a recursive function that…
A: Given: We have to write a Python program to design the number of calculation system.
Q: Write a function called number_matrix (r,c) that takes two parameters r and c and PRINTS ON THE…
A: The matrix is a rectangular arrangement of numbers or data. In a matrix, the horizontal entries…
Q: Write a C++ program that computes and returns: • the smallest positive integer (n) for which…
A: The program includes instructions for solving the problems and outputs the results. The program's…
Q: Write a program in PYTHON with a function max(L) which examines the argument list L, and returns the…
A: 1) Below is python program with a function max(L) which examines the argument list L, and returns…
Q: Suppose you have to design a number calculation system. You need to write a recursive function that…
A: Input : List of list Output : Maximum value in list of list
Q: Using the function provided, write a function that decides whether two lists are "identical". That…
A: Please find the answer below
Q: Please answer it in Python Write a function last_consonant that takes as an argument a word and…
A: Q: Code the given function in python
Q: Write the in_order() function, which has a list of integers as a parameter, and returns True if the…
A: Question given: A list of integer numbers is given. Define a method that check if all integers in…
Q: Write the C equivalent “train” function #void train(int*A, int*B, int*C, int k) train: add…
A: I have decoded the MIPS code and written all 11 instructions with a meaning along with the MIPS…
Q: Write a function timestable(n), which prints a multiplication table of size n. For example,…
A: Python code and code screenshot is given below and Output is also given below:
Q: Write a function little_sum (number_list, limit) that returns the sum of only the numbers in…
A: limit is number is less than or equal all number sum in below function.
Q: Question 4: Write a function that takes three lists of integers, l1, l2, and l3, and returns a list…
A: Note: Below is the required program in python language. Program Approach: Declaring a function that…
Q: In program problem5.py, write a function named sums that takes 3 arguments: 2 lists of integers…
A: A tuple is a data type that store multiple lists of items under a single variable. It is ordered and…
Q: Write a function sum67 that takes a list as an input parameter and returns the sum of the numbers in…
A: Below is the code in python and sample output:
Q: Use the Design Recipe to write a function round_list, which consumes two arguments, a list of floats…
A: I have provided a solution in step 2.
Q: Write a function using Java Function Name: winInRow Parameters: board: 2D integer array, row:…
A: - We need to complete the modified tic tac toe. - We have to use java language here.
Use the Design Recipe to write a function weighted_total(number_list,weights) that consumes a list of numbers and a list of weights and returns the weighted total of the numbers. If the numbers are [1,2,3] and the weights are [0.1,0.5,0.4] then the weighted total should be 1 * 0.1 + 2 * 0.5 + 3 * 0.4 = 2.3
Think about what needs to happen before using a loop, during the loop, and after the loop finishes. In this question you are required to use a for loop, and not allowed to use the sum function.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- You are given a list of integers. Write a function in Python to find the maximum sum that can be obtained by summing non-adjacent elements from the list. The function should return the maximum sum. Example: Input: [2, 4, 6, 8, 5] Output: 13 Explanation: The maximum sum can be obtained by selecting elements 2, 6, and 5 (non-adjacent) and summing them: 2 + 6 + 5 = 13. Input: [5, 1, 1, 5] Output: 10 Explanation: The maximum sum can be obtained by selecting elements 5 and 5 (non-adjacent) and summing them: 5 + 5 = 10. Instructions: Implement a function called max_non_adjacent_sum that takes a list of integers as input. Write the necessary code to find the maximum sum of non-adjacent elements. Return the maximum sum. Test your function with different input cases to validate its correctness.Use Standard ML Code: Write a function that returns the factorial of a number. Write a function that sums all numbers in a list of pairs. e.g.: sum_of_pairs [(1, 2), (4, 3), (2, 5)] should return 17 (which is equal to 1 + 2 + 4 + 3 + 2 + 5) Write a function to return a list of second elements in a list of pairs. e.g.: sends [(1, 2), (4, 3), (2, 5)] should return [2, 3, 5]।I really need help with this problem 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 multiples…
- I need to solve this in C++ code When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by subtracting the smallest value from all the values. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 30 50 10 70 65 the output is: 20 40 0 60 55 For coding simplicity, follow every output value by a space, even the last one. Your program must define and use the following function:int GetMinimumInt(vector<int> listInts) Note: This is a lab from a previous chapter that now requires the use of a function.Write a function in C programming language that gets two ints x and y, and returns the sum of all ints between x and y, including them. int sum_interval(int x, int y); For example: - sum_interval(1, 4)returns 1+2+3+4=10. - sum_interval(10, 3)returns 3+4+5+6+7+8+9+10=52. - sum_interval(2, -1)returns (-1)+0+1+2=2. - sum_interval(-1, -1)returns -1. Note that we may have x>=y or x<=y. You may assume that the sum will be within the range of int.Suppose you are given a list of integers, where each integer represents the maximum number of steps that can be jumped going forward from that element. Write a function to determine if it is possible to reach the last index starting from the first index. For example, given the list [2,3,1,1,4]. you can start at the first index, jump 2 steps to the second index, then jump 1 step to the third index, then jump 1 step to the fourth index, and finally, jump 4 steps to the last index. Therefore, the function should return "True". However, given the list [3,2,1,0,4], it is impossible to reach the last index. Therefore, thef unction should return "False" Solve it in python
- Because floating-point numbers are imprecise, it is common to compute data values of type float that are very close but not exactly equal to the value 0.0. a) In Python, Write a function countNZdata that counts number of elements in a list of type float whose absolute value is less than or equal to a positive tolerance parameter. The function takes the list as its first parameter; the second parameter is the positive float value that is the tolerance. Function should return the number of data values that meet this criterion. For example, for the given list: [2.19, -0.04, 1.66, 0.05, 4.70, -6.53, -0.11, -1.07, 1.94, -2.23] and a tolerance = 0.1, the function should return the value 3. b) Demonstrate that the function works by inputting different example values.The question is in bold and the rest is there for support , to explain concepts Write a function triple_riffle(mylist) which takes as input a list (which for convenience we will always take with length a multiple of 3) and outputs the result of a 3-way riffle shuffle . For example: an input of range(9) should output [6,3,0,7,4,1,8,5,2]. Write a function triple_riffle_repeat(mylist,n) which takes as input a list (again with length a multiple of 3) and outputs the result of doing a 3-way riffle shuffle n times. A Faro shuffle is when a deck of cards is split exactly in half and then the two halves are interleaved exactly. There are two versions: an out-shuffle where the card in position 1 stays where it is (and likewise the card in the last position stays there), and an in-shuffle where the card in position 1 moves to position 2 (and the card in last position moves up one). The following code prints the result of a Faro out-shuffle on the list [1,2,...,52]. deck = list(range(1,53))…A common programming problem is maintaining a list in numerical or alphabetical order. For example, inventory part numbers are typically kept in numerical order, but telephone lists are kept in alphabetical order. For this exercise, write a function that inserts a three-digit part number in a list of part numbers. The list is maintained in increasing numerical order, and duplicate part numbers aren’t allowed. Allocate a maximum list size of 100 values, and use a sentinel value of 9999 to indicate the end of the list. For example, if the current list contains nine part numbers, the 10th position in the list contains the sentinel value. the insertion process for an original list of nine part numbers, using the following processing algorithm: To determine where in the list the new part number should be placed This is done by comparing the new part number to each value in the current list until a match is found, a part number larger than the new part number is located, or the end of the…
- A common programming problem is maintaining a list in numerical or alphabetical order. For example, inventory part numbers are typically kept in numerical order, but telephone lists are kept in alphabetical order. For this exercise, write a function that inserts a three-digit part number in a list of part numbers. The list is maintained in increasing numerical order, and duplicate part numbers aren’t allowed. Allocate a maximum list size of 100 values, and use a sentinel value of 9999 to indicate the end of the list. For example, if the current list contains nine part numbers, the 10th position in the list contains the sentinel value. the insertion process for an original list of nine part numbers, using the following processing algorithm: To determine where in the list the new part number should be placed This is done by comparing the new part number to each value in the current list until a match is found, a part number larger than the new part number is located, or the end of the…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.Sample Run #1:scoreList1 = [9.0, 9.0, 7.5, 8.0, 9.5, 6.5, 5.0, 7.0, 7.5, 8.5]print("The Original ScoreList: ", scoreList1)print(MedianWithoutHL(scoreList1))Output of Sample Run #1:The Original ScoreList: [9.0, 9.0, 7.5, 8.0, 9.5, 6.5, 5.0, 7.0, 7.5, 8.5]The List after sorting: [5.0, 6.5, 7.0, 7.5, 7.5, 8.0, 8.5, 9.0, 9.0, 9.5]Without the High & Low: [6.5, 7.0, 7.5, 7.5, 8.0, 8.5, 9.0, 9.0]7.75Please answer it in Python 1) Write a function last_consonant that takes as an argument a word and returns two return values: the index of its last consonant and the last consonant (as for lists, we will consider that the index of the first letter is zero). We will not deal with the problematic case where the word does not contain a consonant. Example: last_consonant('arrivee') returns 4, 'v' 2) Write a function double_consonant that takes as an argument a word and has two return values: a Boolean worth True if the word contains a double consonant (twice the same consonant in a row), and in this case the second return value is the consonant that is doubled; if there is no doubled consonant, the function must return False and None. If the word contains several double consonants (for example, 'successor'), true will be returned and the first double consonant appearing in the word. Examples: double_consonant('arrive') is True, 'r'. double_consonant ('candy') is false, none…