9.4 Code Practice: Your task is to determine whether each item in the array above is divisible

by 3 or not. If an item is divisible by 3, then leave that value as-is in the

array, but if it is not divisible by 3, then replace that value in the array with a

o. Remember that you will need to use modular division from Unit 2 to

determine if a value is divisible by 3. Finally, print out the array in the

format as seen in the sample run below.

(Can someone please help me?)

Respuesta :

Answer:

Explanation:

The following Python code is a function that takes in an array as a parameter, it then loops through the array determining if the element is divisible by 3. If it is it leaves it alone, otherwise it changes it to a 0. Then ouputs the array. A test case is shown in the attached image below using a sample array.

def divisible_by_three(array):

   for x in array:

       if x % 3 == 0:

           pass

       else:

           array[array.index(x)] = 0

   return array

Ver imagen sandlee09

In this exercise we have to use the knowledge of computational language in python to describe the code, like this:

We can find the code in the attached image.

What is an array for?

After wondering what an array is, you might wonder what it's for. The main purpose is to store information in an orderly way, that is, for each line, one piece of information. An example of an array is when storing names of people present in a classroom.

The code can be written more simply as:

def divisible_by_three(array):

  for x in array:

      if x % 3 == 0:

          pass

      else:

          array[array.index(x)] = 0

  return array

See more about python at brainly.com/question/26104476

Ver imagen lhmarianateixeira