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]
4 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]4 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
Two people, Alice and Bob are using the key sharing algorithm. They have chosen a clock size of 17 and a base of 5. Alice's priv
hjlf

Answer:

fsfsf

Explanation:

6 0
3 years ago
Pig Latin is a nonsense language. To create a word in pig Latin, you remove the first letter and then add the first letter and "
LUCKY_DIMON [66]

Answer:

Hi there  Sandrathompson5661!  

Using Java as the language for implementation, the PigLatin translation program can simply be coded as shown below. The program uses the Scanner module in java utils package to prompt the user for input of word(s) and splits the input with any of the matching delimiters. The rule to swap the first character and append it to the end with an “ay” for a normal word, or the appending of “yay” for a vowel word, is then applied. The result is printed on the screen before the program exits.

Explanation:

import java.util.Scanner;

public class PigLatin {    

 public static void main(String[] args)     {        

   char[] delimiterChars = { ' ', ',', '.', ':', ';', '\t' };        

   String[] words_array;        

   Scanner words = new Scanner(System.in);        

   System.out.println("Please enter a word (for multiple words use any of the following delimiters {' ', ',', '.', ':', ';', '\t' }): ");        

   String input_words = words.nextLine();        

   words_array = input_words.split("[,\\s\\-:.;' '\\\t]");  

   System.out.println("PigLatin translation: ");        

   for (int i=0; i<words_array.length; i++) {

     System.out.println(makePigLatin(words_array[i]));        

   }    

 }      

 public static String makePigLatin(String word)     {        

    String vowels = "aeiou";        

    if (vowels.indexOf(Character.toLowerCase(word.charAt(0))) != -1) {          

       word = word + "yay";        

    }        

    else {          

       word = word.substring(1, word.length()) + word.charAt(0) + "ay";        

    }        

    return word;      

 }

}

7 0
3 years ago
Write the definition of a method printarray, which has one parameter , an array of int s. the method does not return a value . t
stealth61 [152]
<span>void printArray(int a[ ]) {
</span> int i;   <span>for (i = 0; i &lt; a.length; i++){
</span>  <span>System.out.print(a[i]);
</span> System.out.println();   <span>}
</span> }
6 0
3 years ago
A while loop's body can contain multiple statements, as long as they are enclosed in braces
algol [13]

Answer:

True

Explanation:

while loop is used to execute the statement again and again until the condition is true. if condition False program terminate the while loop and start execute the statement outside the loop.

syntax:

initialize;

while(condition)

{

  statement 1;

  statement 2;

   to

  statement n;

}

we can write multiple statement within the braces. their is no limit to write the statement within the body of the while loop.

while terminate only when condition false

4 0
4 years ago
What does the MLA style not require that both the APA and Turabian do
snow_lady [41]

Dunno if this helps but here goes nothin

An APA-formatted paper includes the author's last name and year of publication in parenthesis after the cited text. An MLA-formatted paper includes the author's last name and page number in parenthesis after the text.

3 0
4 years ago
Other questions:
  • Regarding computer protection, quarantining is defined as ________. Select one: A. placing a found virus in a secure area on the
    13·1 answer
  • What does it mean when #DIV/0! is displayed and a green triangle is added to the upper-left corner of a cell? A. The formula can
    10·2 answers
  • Which is the most important reason you should properly cite information that you obtain from an Internet search? Question 2 opti
    8·1 answer
  • You have a large company, and it is important to your business that your employees' work is backed up regularly. Which network w
    5·1 answer
  • What would be advantageous for a laptop user to carry when the laptop gets a lot of use?
    14·1 answer
  • Write a complete program whose class name is hello and that displays hello, world on the screen.
    13·2 answers
  • Intuitively, which of the following would happen to e⃗ net if d became very large?
    6·1 answer
  • What justification can you give for normalizing a database if the database will be updated only by the people who can be trusted
    11·1 answer
  • Fullform of mips plz ​
    8·1 answer
  • The function ________ returns a value or reference of the cell at the intersection of a particular row and column in a given ran
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!