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
Komok [63]
2 years ago
9

Write a function square_evens(values) that takes a list of integers called values, and that modifies the list so that all of its

even elements are replaced with their squares, but all of its odd elements are left unchanged.
Computers and Technology
1 answer:
Mice21 [21]2 years ago
5 0

Answer:

#create the function

def square_evens(values):

   count_Value = 0

   #loop loop for iteration

   for i in values:

       #check for even number

       if (i) % 2 == 0:

           values[count_Value] = i * i  #store the square in the same index

       count_Value =count_Value + 1

   print(values)  #print the list

# list of integers

values = [1, 2, 3, 4, 5, 6]

#calling the function

square_evens(values)

Explanation:

The above code is written in python. first, create the function square_evens() which takes one parameter of the list.

inside the function declare the variable and then take a for loop for traversing each element in the list. Inside the for loop, we take the if-else statement for checking the number is even. if the number is even then stored the square of that value in the same list. To store the square value in the same index, we take the count variable for tracking the index.

After the all element in the list checked, the program terminates the loop and then print the updated list on the screen.

Outside the function, create the list with an integer value and then calling the function with passing the list argument.  

NOTE: In the python programming, please keep the indentation in code.

You might be interested in
Consider the following code segment. for (int a = 0; a < 10; a++) { for (int b = 10; b > a; b--) { System.out.print("#");
Ket [755]

Answer:

55

Explanation:

Given the codes as below:

  1.        for (int a = 0; a < 10; a++)
  2.        {
  3.            for (int b = 10; b > a; b--)
  4.            {
  5.                System.out.print("#");
  6.            }
  7.        }

There are two layer loops in the code. The outer loop (Line 1) will run for 10 iterations by traversing through a = 0 to a=9. However, the inner loop  (Line 3) will run for 10 + 9 +  8 + 7 +...+ 1 = 55 iterations.

Since the print statement is within the inner loop (Line 5) and therefore the number of printed "#" symbols is dependent on the number of iterations of the inner loop. There will be 55 "#" symbols printed.

6 0
3 years ago
Identify a true statement about heuristics: a. They are more complicated than algorithms. b. Unlike algorithms, they do not perm
STatiana [176]

Answer:

The appropriate alternative is Option d.

Explanation:

  • Heuristic also seems to be essentially a methodology that solves numerous major issues in an even cheaper manner. It requires less effort than those of the traditional techniques. It's providing accurate solutions. It has a broader potential in the treatment of computer engineering. It is already being shown in quantum computing.
  • Mathematical implementations also contribute significantly to heuristics. This could make concessions on the component of optimal performance. It can also make concessions on the degree of consistency. It helps to achieve international headquarters at quite a quicker speed.

The latter decisions made are not connected to the conditions. So the above comment is correct.

4 0
3 years ago
What is a best practice when approaching an automation effort?
Ksivusya [100]

Answer:

improving the current process before automating it

6 0
3 years ago
An organization is concerned with the amount of sensor data that is being generated locally, analyzed in the cloud, and returned
Sonja [21]

Answer:

Fog computing

Explanation:

Fog computing or fogging is an decentralized architecture that resides between the cloud and the data source. Fog brings the cloud closer to the data source, that is, it brings resource exploitation, security polices and operational cost closer to the data source.

In our scenario, with fogging in place, the generated sensor data will be preprocessed closer to the local site. The data will preprocessed faster and the quality of the processed data will be greatly increased.

3 0
3 years ago
What is the difference, if any, between secure HTTP and firewalls?
Jobisdone [24]

Answer:

SSL would simply encrypt whatever request is sent to the server. In order to prevent the execution of such malicious scripts/payloads at the Web application (in other words the Web server), a Web Application Firewall is implemented in place. ... Whereas, HTTPS where SSL comes into picture would have methods such as POST.

in other words its A

5 0
3 years ago
Other questions:
  • Desktop, laptop, and tablet computers, and mobile devices are classified as _______.
    7·1 answer
  • Which of the following dimensions of e-commerce technology involves the integration of video, audio, and text marketing messages
    11·1 answer
  • Write an application that determines the value of the coins in a jar and prints the total in dollars and cents. Read integer val
    6·2 answers
  • Number Array Class
    5·1 answer
  • 3. When you right-click a linked spreadsheet object, what commands do you choose to activate the Excel features?
    7·2 answers
  • Consider two communication technologies that use the same bandwidth, but Technology B has twice the SNR of technology A. If tech
    14·1 answer
  • If tech is smarter than us. How did a human make something smarter than him/her?
    9·2 answers
  • What is the diffrent between ibm pc and ibm compatibles in table:​
    11·1 answer
  • Que ventajas podria traer el internet a la educacion artistica? Ayuda porfa telo pido porfavor
    13·1 answer
  • (Synchronized threads) Write a program that launches 1000 threads. Each thread adds a random integer (ranging from 1 to 3, inclu
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!