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
Do anyone else receive random points from Brainly… because I swear I had like 2K+ something and I check and Im at ACE… and with
sergiy2304 [10]

Answer:

i had the same thing happen to me and no it doesnt make sense at all but....i found something out a while ago...

Explanation:

they have achievements and it helps with how you earn points and level up

6 0
3 years ago
How tp access to all tools in ms word
Tresset [83]
Wigga woggga wigggawiggva
8 0
3 years ago
Why is dark supereffective against ghost?
Mice21 [21]

Answer:

hmmmmm...hold up let me look up what dark supereffective means XD...

Explanation:

?oh so i only see stuff about pokemon so id imagine its about that...

4 0
3 years ago
Read 2 more answers
To avoid potential documentary errors and security leaks, the configuration of firewalls should not be documented unless strictl
Zolol [24]

Answer: False

Explanation:

 The given statement is false, as the configuration of the firewall, operational and administration procedure must be documented.

The configuration of multiple firewall are identical and the integrity and also performance of the configuration firewall files are check on the regularly bases.

It is basically used to avoid the security leaks and the documentation errors so it is necessary that it should be check regularly so that it can easily implement without any interrupt occurrence.

8 0
3 years ago
How do we make a acount
IRISSAK [1]
Press sign up and put your information in there. Then it should automatically make your profile.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Esther has acquired an associate's degree in information technology and certifications in PageMaker and Illustrator. Which caree
    8·2 answers
  • The two variables causing the point of difference between the time codes are the frequency and the count
    6·1 answer
  • 7.
    6·1 answer
  • What is the smallest unit of data on the hard drive?
    5·1 answer
  • A user calls to report that she is experiencing intermittent problems while accessing the wireless network form her laptop compu
    9·1 answer
  • What are the five types of alignment in Word?
    12·2 answers
  • Jennifer works as a clerk in a company. The essential function of her job is typing on a keyboard. If she develops crippling art
    11·1 answer
  • PLEASE HELP!!!!
    6·2 answers
  • Which professionals can benefit from an understanding of statistics? Check all of the boxes that apply. magician trying to locat
    5·2 answers
  • To open a Google Doc in another software application, the user must first download it. True or false?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!