Define an array to be a Mercurial array if a 3 does not occur between any two 1s. Write a function named isMercurial that returns 1 if its array argument is a Mercurial array, otherwise it returns 0

Respuesta :

The Mercurial array program is an illustration of arrays, loops and conditional statements

How to write the program?

The program written in Python, where comments are used to explain each action is as follows:

#This defines the function

def checkMercurialarray(myarr):

   #This checks if the array contains 3

   if myarr.count(3) > 0:

       #If yes, this checks if the elements before and after 3 is 1

       if myarr[myarr.index(3)- 1] == 1 and myarr[myarr.index(3)+ 1] == 1:

           #This returns 1 if true

           return "1"

   #This returns 0

   return "0"

Read more about Python programs at:

https://brainly.com/question/26497128

#SPJ1

ACCESS MORE
EDU ACCESS