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
The Windows taskbar is generally found _____. at the top of the screen in the Start menu at the bottom of the screen at the righ
rjkz [21]
At the bottom of the screen.
4 0
3 years ago
Read 2 more answers
Which skill type refers to the knowledge and ability to perform a task?
Thepotemich [5.8K]

Sound, Audio for engineering sound Quality's.

7 0
3 years ago
Read 2 more answers
To be useful for most household applications, DC voltage is?please <br>​
satela [25.4K]

Answer: To be useful for most household applications, DC voltage is passed through a step-down transformer.

Explanation: Voltage coming through AC or DC outlets is typically far too high for most household appliances to handle, so the current is passed through a step-down transformer to reduce the voltage to a usable level.

3 0
2 years ago
Why is making a model, or prototype, important in the design process?
seropon [69]

Explanation:

to size up and define your works organize and having a creative thoughts and imaginations in it to properly execute the measurement of the clothes.

8 0
3 years ago
​Which of the following languages is used to set the width of a media player, add borders, drop shadows, and apply filters and t
NARA [144]

Answer:

B. CSS

Explanation:

CSS is a language used to format or add styling to web components like the media player. style rules such as borders, drop-shadows, filters, transformation, etc, are added using CSS. CSS stands for Cascading Style Sheets, it is the core three languages needed to create a website, CSS is used alongside HTML and JavaScript, where HTML provides structure, CSS adds styling and JavaScript adds interactivity.

4 0
3 years ago
Other questions:
  • The system administrator in your office quits unexpectedly in the middle of the day. It's quickly apparent that he changed the s
    10·1 answer
  • Which of the following would be a tradeoff of a scientific advancement that enables us to catch fish from the ocean faster than
    5·1 answer
  • Describe a time when you influenced someone else’s knowledge around technology, whether it be an app, a new gadget, etc. What di
    14·1 answer
  • What is an example of how pseudo - randomness is used to creative variation​
    5·1 answer
  • The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
    10·1 answer
  • The picture that graphically represents the items you use in Windows is called a/an <br> ___?
    14·1 answer
  • ABC IF U HAVE A LEGENDARY PET ON ADOPT ME OR ANYTHING COOL!! &lt;3
    5·2 answers
  • True false.
    10·2 answers
  • 1. Give one reason why data is represented in binary in a computer [1]
    10·1 answer
  • open your browser and enter the address of this ftp site in the address box: ftp.cengage. if your browser supports ftp, a logon
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!