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
(Giving away points!)
Komok [63]

Answer:

Used to lol not anymore tho :p

8 0
2 years ago
So wait how do i comment on someone's answer because that would be useful ,,.
LuckyWell [14K]

Answer:

Type right under my comment

Explanation:

Look in comments

5 0
3 years ago
Read 2 more answers
A friend has a CD of one of your favorite artists and has offered to let you copy it.
creativ13 [48]
No; copyright laws protect this artist's rights and I need to purchase the CD if I want it.  

This is due to copyrights being applied at the time of fixation.  In other words, as soon as the words or lyrics have been placed on paper, recorded or put in a computer the ARTIST is protected.
6 0
3 years ago
Compare userNumber with compareNumber and display 'Numbers are not equal' if the numbers are different. Then, display 'Variables
masya89 [10]

Answer:

Following are attached images that will help you understand the complete code. The code is tested with different variables and different outputs are obtained. All the necessary description is given in the form o comments inside the code.

Explanation:

3 0
3 years ago
A set of well-defined steps for performing a task or solving a problem is known as a(n):A) HierarchyB) AlgorithmC) Central Proce
RideAnS [48]

Answer:

The correct answer to the following question will be Option B (Algorithm).

Explanation:

  • An algorithm seems to be a countable series of very well-defined, machine guidance that is implementable, and are generally used to solve a group of issues and to perform a calculation.
  • It is widely used for processing of the data, computation and other associated computational and numerical activities.
  • A coding algorithm is a process of the computer that's a lot like just a formula that tells the machine precisely what actions you need to follow to fix a problem or achieve a goal. 

The other three options will not be able to fix the problems that arise while achieving a goal, execution of a function or creating program code.

Therefore, Option B is the right answer.

5 0
3 years ago
Other questions:
  • The standard qwerty keyboard has 47 keys that can place characters on the screen. each of these keys can also display a second c
    13·2 answers
  • What are the 7 basic components found in a computer tower
    5·2 answers
  • Write a program that displays the following pattern: ..\.\* .\.\*** \.\***** ******* \.\***** .\.\*** ..\.\* That is, seven line
    8·1 answer
  • WILL GIVE BRAINLIEST TO FIRST AND BEST ANSWER!
    10·1 answer
  • Name at least two types of career options that are available for someone with strong typing skills?
    10·2 answers
  • You want to join your computer to a homegroup but you don't see any homegroups on your home network
    11·1 answer
  • State why hexadecimal is used to display the error code
    11·1 answer
  • Why did Herman Hollerith invent the Tabulating Machine?
    10·1 answer
  • Find the number of times a value appears in a list, and create a new list that contains the index positions where the value occu
    6·1 answer
  • Which type of image format is constructed using proportional formulas rather than pixels? This task contains the radio buttons a
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!