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]
3 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]3 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
What command is used to add a reflection or an outline to text
WARRIOR [948]

text effects, and typography.

6 0
3 years ago
Before you can use a navigation control, you must _____. A. configure the web.config B. configure the global.asax C. configure t
natita [175]

Answer:

C

Explanation:

6 0
3 years ago
Read 2 more answers
Outline three difference each of a raster filled and vector file​
Alekssandra [29.7K]

Answer:

Unlike raster graphics, which are comprised of colored pixels arranged to display an image, vector graphics are made up of paths, each with a mathematical formula (vector) that tells the path how it is shaped and what color it is bordered with or filled by.

Explanation:

7 0
3 years ago
What tool is used to find and organize files on a mac
Margaret [11]

Answer:

the tool is literally called <u><em>The Finder.</em></u>

Explanation:

hope this helps

4 0
3 years ago
.9 What is Artificial Intelligence?
Serhud [2]
C because bread is not happy with you
8 0
3 years ago
Other questions:
  • Plugging in a cable is a good troubleshooting technique. <br> True or false
    5·1 answer
  • Which of the following is 1000 of a second​
    15·1 answer
  • Object Linking and Embedding (OLE) data integration allows you to
    8·1 answer
  • You can send messages that include photos and videos between mobile devices using ________ technology.
    12·1 answer
  • True / False<br> The exponent in floating point is stored as a biased value.
    9·1 answer
  • Pleaseeee help me w this!
    10·1 answer
  • Alan has introduced a new line of scooters on his website and is using a Google Display Ad campaign to promote them. He selects
    8·1 answer
  • When spraying pesticide wear and protective eyeglass​
    13·2 answers
  • Alayna is researching information online to write her essay about the Berlin Wall.
    8·1 answer
  • 3.8 LAB: Read values into a list
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!