Question: Using Python. Thanks Nice Sequence def nice(check): '''The for loop iterates through the list''' for i in range(1,len(check)): # The if condition checks if the

Using Python. Thanks

Using Python. Thanks Nice Sequence def nice(check): '''The for loop iterates through

Nice Sequence

def nice(check): '''The for loop iterates through the list'''  for i in range(1,len(check)): # The if condition checks if the value is not in the range and if any of the number  # is a multiple or divides the number before it . If this holds good it prints false  # and exits .  if(not(check[i]%check[i-1]==0 or check[i-1]%check[i]==0) or (check[i] check[i]>100)): print("False") exit() # Suppose the test case passes through all the iterations without exiting then it  # is a nice series .  print("True") nice([5,1,100,50,10]) 

3(Nice sequences, 10pt, Remember nice sequences? If not, go back to roblem4onhomework2. You want to turn nice sequences into an interactive game, activated by calling nice). The player gets to enter one number at a time, and, as long as the number doesn't destroy niceness, you add the number to the sequence and display the current sequence and its length. If the user simply hits retum, the program stops summarizing the current result. See below for a screenshot: Python 352 Shell Number: 5 Length 1: 5 Number: 10 Length 2: 5, 10 Number: 2 Length 3: 5, 10, 2 Number: 8 Length 4: 5, 10, 2, 8 Number: 4 Length 5: 5, 10, 2, 8, 4 Number: You found a nice sequence of length 5: [5 10, 2, 8, 4] Bye If the player violates any of the niceness conditions, the program tells the player what happened, and stops the game. See below for screenshots. Python 3.52 Shell nice ( Number: 5 Length 1: 5 Number: 2 Fail: violated divisibility condition >>>nice () Number: 5 Length 1: 5 Number 10 Length 2: 5, 10 Number: 5 Fail: duplicate value >>>nice () Number: 5 Length 1: 5 Number: 105 Fail: out of range Ln 96 Co Hint: one step at a time. How did I get rid of the brackets when displaying the list? It's easier than you think. You can assume that the users enter only integers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!