1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Fudgin [204]
3 years ago
11

The scheme function (mult2-diff Ist) should take one argument, a list of numbers, and results in multiplying each number in the

list by two and then computing the difference of those numbers, e.g.: (mult2-diff'(912)) should evaluate to the difference of 18, 2 and 4: (18-2)-4, or 12. Finish mult2-diff below: (define (mult2-diff lst) (if
Computers and Technology
1 answer:
JulijaS [17]3 years ago
6 0

Answer:

The solution code is written in Python.

  1. def mult2_diff(lst):
  2.    num_list = []
  3.    for x in lst:
  4.        num_list.append(x * 2)
  5.    diff = num_list[0]
  6.    for i in range(1, len(num_list)):
  7.        diff = diff - num_list[i]
  8.    
  9.    print(diff)

Explanation:

Firstly, based on the requirement stated in the question, define a function <em>mult2_diff() </em>that takes one argument, <em>lst</em>, which is a list of numbers (Line 1).

This function is expected to multiply each number in the list by two and then followed with computing the difference. To do so, let's try to attempt the first function task, multiplying numbers.  Create a new list, num_list, to hold the multiplied numbers (Line 2). Use a for loop to traverse through each number in the input list, <em>lst</em>, and multiply each of them by two and add it to the <em>num_list </em>(Line 4-5).

To attempt the second function task, create another variable, <em>diff</em>, to hold the value of calculated difference between the numbers in the <em>num_list</em>. Initialize <em>diff </em>with the first number in the <em>num_list</em>. Use a another for-loop to traverse through each number in the num_list starting with second index, <em>1</em>, and calculate the difference between the <em>diff </em>and the current number extracted from the <em>num_list </em>through indexing.

At last print the output of <em>diff</em> (Line 11).

You might be interested in
Match the limits of the user with an appropriate design response. 1. severe arthritis, unable to type or use a mouse on a reliab
ololo11 [35]
Idk........................
4 0
3 years ago
For python how do I ask the user how many numbers they want to enter and then at the ending add those numbers up together?
Digiron [165]

I am not too familiar with the Python language, but the algorithm would be something like this:

1. create a variable for the sums of the number

2. read in how many numbers the user wants to enter (let's call it N)

and then create a for loop:

for N times

read in the next number

increase the sum variable by that number

Hopefully this helps!

8 0
3 years ago
Write a function sample_median(n,P) that generates n random values using distribution P and returns the median of the collected
TiliK225 [7]

Answer:

import numpy as np

def sample_median(n, P):  

   return np.median( np.random.choice ( np.arange (1, len(P) + 1 ), n, p = P ) )

print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))

print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))

print(sample_median(5, [0.3,0.7])

print(sample_median(5, [0.3,0.7])

Explanation:

  • Bring in the numpy library to use the median function provided by the numpy library.
  • Define the sample_median function that takes in 2 parameters and returns the median with the help of built-in random, choice and arrange functions.
  • Call the sample_median function by providing some values to test and then display the results.    

Output:

4.5

4.0

2.0

1.0

7 0
2 years ago
Design a database to keep data about college students, their academic advisors, the clubs they belong to, the moderators of the
alekssr [168]

Answer:

Complete design is attached below.please have a look.

Explanation:

8 0
3 years ago
Read 2 more answers
Two Technicians are discussing Tire Fitment information.
IRISSAK [1]

Only technician A is correct.

Technician A only

<u>Explanation:</u>

According to technician A, tire fitment information provides specific specs of the vehicle including the inflation pressure, OEM tire size, and lug nut tire sequences. The class of vehicles is divided into a category of vehicles and these categories are further specialized to form different models. Each model has its own specifications and their requirements differ from one another.

Hence the tire fitment of each vehicle should convey specific information about the model in concern. For instance, the optimum inflation pressure of a Royal En field will not be the same as that of Hero Splendour as both have a huge difference in their respective weight and size.

4 0
3 years ago
Other questions:
  • A data structure used to bind an authenticated individual to a public key is the definition of ________.
    14·1 answer
  • Instructions:Select the correct answer.
    13·1 answer
  • Given positive integer numInsects, write a while loop that prints that number doubled without reaching 100. Follow each number w
    8·1 answer
  • Which of these automotive repair areas helps the vehicle change speeds to operate efficiently under all conditions?
    5·1 answer
  • For conditional formatting, a formula must be in the form of a(n) _____ test that results in a true or false value. Question 1 o
    8·1 answer
  • Tcp takes a three-step approach to establishing a reliable communication. first, from the transport layer of the sending device
    12·1 answer
  • Select the correct answers
    9·1 answer
  • What is an aspect ratio?
    6·1 answer
  • What are the fundamental activities that are common to all software processes?
    9·1 answer
  • Prior to the 1996 NEC, ____ receptacles and cords were permitted. However, now it is mandatory that a separate equipment groundi
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!