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
Ostrovityanka [42]
3 years ago
15

Given the list of customer segments below please create a new list of the names of the segments only using(a) a for loop(b) a li

st comprehension(c) a map().List would look something like ['Wallstreet','Gambler','Parents'] but of course using each tool as listed:segments = [{'name': 'Wallstreet', 'average_spend': 82.01}, {'name': 'Gambler', 'average_spend': 107.00}, {'name': 'Parents', 'average_spend': 10.52}]
Computers and Technology
1 answer:
Alchen [17]3 years ago
7 0

Answer:

new_segment = [ ]

for segment in segments:

   new_segment.append({'name': segment, 'average_spend': money})

print( new_segment)

Using list comprehension:

new_segment =[{'name': segment, 'average_spend': money}  for segment in segments]

Using map():

def listing(a):

   contain =  {'name': segment, 'average_spend': money}

   return contain

new_segment = [ ]

new_segment.append(map( listing, segment))

print(list(new_segment)

Explanation:

The python codes above create a list of dictionaries in all instances using for loop, for loop in list comprehension and the map function which collect two arguments .

You might be interested in
When you use the ip address of the web server, the correct site is displayed?
jekas [21]
No. Using the address will get you either the default site, or the first site declared. Web servers can host VirtualHosts, and rely on the site name to know which VirtualHost to serve. TMI, it's called name based virtual host, as opposed to the machine having many addresses then address based virtual hosts can be created.
6 0
3 years ago
Part 2: Code the Program
OverLord2011 [107]

Answer:

# Name - Today's Date

# Description

def main():

    print("My favorite TV show is Mythbusters.")

    print("I like it because I learn a lot and they do crazy experiments.")

main()

(this is the best I can do since it's a specific result based on the choices you make, but I did the example code and you just need to fill it in with the necessary requirements. I also tested it on IDLE. )

8 0
2 years ago
Application Software include programs like: MS Word, Google Docs, MS Exce ect...
ycow [4]

Answer: True A.

Explanation: Every app has or needs a program

By demmaku :v

7 0
3 years ago
Security and protection as it relates to operating systems is grouped into four categories: Availability, Data integrity, Authen
Ivahew [28]

Answer:

The answer is "Confidentiality".

Explanation:

Data Security is also known as protection against unauthorized computer access, files, and pages through digital information protection. The protection of data also prevents data from bribery.  

  • It applies to both the security of data from unwanted entities being obtained.
  • It allows accessing sensitive data, which may be able to do so.
4 0
3 years ago
Write a RainFall class that stores the total rainfall for each of 12 months into an array of doubles. The program should have me
RSB [31]

Answer:

Explanation:

The code provided worked for the most part, it had some gramatical errors in when printing out the information as well as repeated values. I fixed and reorganized the printed information so that it is well formatted. The only thing that was missing from the code was the input validation to make sure that no negative values were passed. I added this within the getMonths() method so that it repeats the question until the user inputs a valid value. The program was tested and the output can be seen in the attached image below.

import java.io.*;

import java.util.*;

class Rainfall

{

   Scanner in = new Scanner(System.in);

   private int month = 12;

   private double total = 0;

   private double average;

   private double standard_deviation;

   private double largest;

   private double smallest;

   private double months[];

   public Rainfall()

   {

       months = new double[12];

   }

   public void setMonths()

   {

       for(int n=1; n <= month; n++)

       {

           int answer = 0;

           while (true) {

               System.out.println("Enter the rainfall (in inches) for month #" + n + ":" );

               answer = in.nextInt();

               if (answer > 0) {

                   months[n-1] = answer;

                   break;

               }

           }

       }

   }

   public void getTotal()

   {

       total = 0;

       for(int i = 0; i < 12; i++)

       {

           total = total + months[i];

       }

       System.out.println("The total rainfall for the year is " + total);

   }

   public void getAverage()

   {

       average = total/12;

       System.out.println("The average monthly rainfall is " + average);

   }

   public void getLargest()

   {

       double largest = 0;

       int largeind = 0;

       for(int i = 0; i < 12; i++)

       {

           if (months[i] > largest)

           {

               largest = months[i];

               largeind = i;

           }

       }

       System.out.println("The largest amount of rainfall was " + largest +

               " inches in month " + (largeind + 1));

   }

   public void getSmallest()

   {

       double smallest = Double.MAX_VALUE;

       int smallind = 0;

       for(int n = 0; n < month; n++)

       {

           if (months[n] < smallest)

           {

               smallest = months[n];

               smallind = n;

           }

       }

       System.out.println("The smallest amount of rainfall was " + smallest +

               " inches in month " + (smallind + 1));

   }

   public static void main(String[] args)

   {

       Rainfall r = new Rainfall();

       r.setMonths();

       r.getTotal();

       r.getSmallest();

       r.getLargest();

       r.getAverage();

   }

}

8 0
2 years ago
Other questions:
  • A(n) _______ allows an attacker to use a network structure to send large volumes of packets to a victim.
    5·1 answer
  • Which of the following statements best compares and contrasts the role of story writers and script writers
    12·1 answer
  • What is industry 4.0 -automation revolution-, what is your opinion about the direction this revolution is taking the industry in
    8·1 answer
  • CNG and gasoline-powered vehicles use the same internal combustion engine, but different fuel types. A) True B) False
    8·2 answers
  • The ____ allows a core to communicate with other cpu components, such as the memory controller and other cores
    14·1 answer
  • keeping in mind the role in order of precedence plays in equations, what would excel display as the result of the following equa
    14·1 answer
  • Write a function ngrams(n, tokens) that produces a list of all n-grams of the specified size from the input token list. Each n-g
    6·1 answer
  • Need answer ASAP.
    8·1 answer
  • A large retail company hires several new joiners and would like to incorporate Virtual Reality (VR) into their onboarding proces
    11·1 answer
  • _______________________ variables do not need to be declared inside the function definition body, they get declared when the fun
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!