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
Travka [436]
3 years ago
7

SUMMING THE TRIPLES OF THE EVEN INTEGERS FROM 2 THROUGH 10) Starting with a list containing 1 through 10, use filter, map and su

m to calculate the total of the triples of the even integers from 2 through 10. Reimplement your code with list comprehensions rather than filter and map.
Computers and Technology
1 answer:
hichkok12 [17]3 years ago
8 0

Answer:

numbers=list(range(1,11)) #creating the list

even_numbers=list(filter(lambda x: x%2==0, numbers)) #filtering out the even numbers using filter()

triples=list(map(lambda x:x*3 ,even_numbers)) #calculating the triples of each even number using map

total_triples=sum(triples) #calculatting the sum

numbers=list(range(1,11)) #creating the list

even_numbers=[x for x in numbers if x%2==0] #filtering out the even numbers using list comprehension

triples=[x*3 for x in even_numbers] #calculating the triples of each even number using list comprehension

total_triples=sum(triples) #calculating the sum.

Explanation:

Go to the page where you are going to write the code, name the file as 1.py, and copy and paste the following code;

numbers=list(range(1,11)) #creating the list

even_numbers=list(filter(lambda x: x%2==0, numbers)) #filtering out the even numbers using filter()

triples=list(map(lambda x:x*3 ,even_numbers)) #calculating the triples of each even number using map

total_triples=sum(triples) #calculatting the sum

numbers=list(range(1,11)) #creating the list

even_numbers=[x for x in numbers if x%2==0] #filtering out the even numbers using list comprehension

triples=[x*3 for x in even_numbers] #calculating the triples of each even number using list comprehension

total_triples=sum(triples) #calculating the sum

You might be interested in
Write a program using integers userNum and x as input, and output userNum divided by x four times. Ex: If the input is 2000 2, t
BaLLatris [955]

Answer:

import java.util.Scanner;

public class Division {

   public static void main(String[] args) {

    Scanner in = new Scanner(System.in);

       System.out.println("Enter an integer");

       int userNum = in.nextInt();

       System.out.println("Enter the divisor");

       int x = in.nextInt();

           int first = userNum/x;

           int second = first/x;

           int third = second/x;

           int fourth = third/x;

       System.out.println(first+" "+second+" "+third+" "+fourth);

   }

}

Explanation:

  • In Java programming langauge use the scanner class to receive the values from the user (userNum and x)
  • Carryout integer division of userNum/x to obtain the first number
  • Repeat the sam step to obtain the second, third and fourth number
  • Output the numbers to the user
5 0
3 years ago
Can't get Brainly to load on my Apple Mac. Why won’t it load? Does it need another program to work?
Lorico [155]

Answer:

Did you download it or did you open it in a "New Tab"?

6 0
2 years ago
Read 2 more answers
In order to paint a wall that has a number of windows, we want to know its area. Each window has a size of 2 ft by 3 ft. Write a
Eva8 [605]

Using the knowledge in computational language in JAVA it is possible to write a code that write a program that reads the width and height of the wall and the number of windows, using the following prompts

<h3>Writting the code:</h3>

<em>import java.util.Scanner;</em>

<em>public class WallArea {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner sc = new Scanner(System.in);</em>

<em>        final int areaOfWindows = 6;</em>

<em>        System.out.print("Wall width: ");</em>

<em>        double width = sc.nextDouble();</em>

<em>        System.out.print("Wall height: ");</em>

<em>        double height = sc.nextDouble();</em>

<em>        System.out.print("Number of windows: ");</em>

<em>        double numberOfWindows = sc.nextDouble();</em>

<em>        double area = (width * height) - (numberOfWindows * areaOfWindows);</em>

<em>        System.out.println("Area: " + area);</em>

<em>    }</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

4 0
1 year ago
The section of the Telecommunications Act that attracted the most attention was the one calling for the creation of ______, whic
jekas [21]

Answer:

the V-chip

Explanation:

8 0
2 years ago
How to create a checkerboard on Python turtle?
mafiozo [28]

Answer:

here is my crude attempt:

import turtle

t = turtle.Turtle()

t.speed(0)

colors = ["black", "yellow"]

SQUARES = 8

SQUARESIZE = 20

def rectangle(color, s):

 t.begin_fill()

 t.pendown()

 t.color(color)

 for i in range(4):

   t.forward(s)

   t.right(90)

 t.end_fill()

 t.penup()

for row in range(SQUARES):

 for col in range(SQUARES):

   t.setpos(row*SQUARESIZE, col*SQUARESIZE)

   rectangle(colors[(row+col)%2], SQUARESIZE)

6 0
3 years ago
Other questions:
  • Explain the function of the Ribbon in Microsoft Word.
    15·1 answer
  • In the accompanying figure, the split double arrow mouse pointer____.
    7·1 answer
  • COMPUTER SCIENCE:PIXELS
    5·1 answer
  • Which of the following describes colors, spacing, borders, and other effects that change the appearance of a table?
    5·1 answer
  • Betty set up an account on a popular social networking website. she wants to know whether the privacy policy is effective for he
    14·1 answer
  • 12. ______ is considered to be the first video game mascot.
    7·1 answer
  • This is a human-made physical system.
    15·1 answer
  • Convert this hexadecimal number to binary :. A07F​
    14·1 answer
  • X = 10<br> y = 20<br> x &gt; У<br> print("if statement")<br> print("else statement")
    12·1 answer
  • Redesign the cover of science textbook using at least two different graphics​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!