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
sdas [7]
3 years ago
14

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:
Assoli18 [71]3 years ago
4 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
Help plz technological wuestion
Alex787 [66]
The first answer is the correct one
8 0
3 years ago
The default ____ for a hyperlink is the folder location and the name of the file to which you will link.
ycow [4]
Title is used
hope it helps
6 0
4 years ago
discuss the advantages and disadvantages that Excel has in helping navigate databases, big data, and data analytics.
posledela

Answer:

 The main advantage of using the the excel that help in navigating the databases and helps in data analytics. It basically exploring huge information and databases are predominantly the information purging methods in exceed expectations which aides in preparing information in an expedient and proficient way.

The information purging procedure incorporate VBA macros or rotate tables, mapping instruments, report causing utilizing progressed to exceed expectations devices and furthermore has the upside of reconciliation with different virtual products.

The disadvantage are as follows:

  • It is difficult for sharing the spreadsheet in the system.
  • It also face difficulty while observing the any type of the regular tends in the given data.

5 0
4 years ago
What is the magnitude of the largest positive value you can place in a bool? a char? an int? a float? a double??
Elena L [17]
The <span>magnitude of the largest positive value you can place in a bool, a char, an int, a float, a double are as follows:

</span><span>Int: 4 bytes Float: 4 double: 8 char: 1 boolean: 1
</span>
I hope my answer has come to your help. God bless and have a nice day ahead!
8 0
4 years ago
Consider the following class definitions.public class Bike{private int numWheels = 2;// No constructor defined}public class EBik
nadya68 [22]

Answer:

The answer is "Option A".

Explanation:

Please find the complete program in the attached file.

The given program includes a super-class Bike having a private integer numWheels parameter. The class EBike inherits the class Bike, EBike comprises one parameter function Object() which utilizes its variable number of the private integer Battery level of the battery parameter and the wrong choice can be defined as follows:

In choice B, it is wrong since there is no constructor with a single argument in the Bike class.

In choice C, it is wrong since there no need to call the base class constructor with the super keyword.

In choice, D is wrong because there no need to create a constructor of the base class.

In choice, E is wrong because it does not require the second EBike constructor parameter.

4 0
3 years ago
Other questions:
  • If you delete a file from removable media, it is stored in the recycle bin where you can recover it until you empty the recycle
    13·1 answer
  • What is SAFFiR? (The robot)
    12·1 answer
  • If you attempt an edgeunity quiz is your latest attempt the one counted?
    10·1 answer
  • Servlet session and JSP session have differentabilities.<br>? True<br><br>? False
    15·1 answer
  • What feature, new to Windows Server 2012, provides the ability to find identical sets of data on a SAN-based storage array and r
    13·1 answer
  • Name the type of software which provides the user interface. [1 mark
    5·1 answer
  • What is another word for: a location in memory that contains a value?
    7·2 answers
  • Can you distinguish between the following examples and determine which one is NOT creative work? a. software b. slogan c. screen
    15·1 answer
  • If you delete search results, you will a. clear the history on the computer. b. delete files from our computer. c. modify the re
    14·1 answer
  • Project: Design and Development Research Project
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!