Write a function called 'game_of_eights()' that accepts a list of numbers as an argument and then returns 'True' if two consecutive eights are found in the list. For example: [2,3,8,8,9] -> True. The main() function will accept a list of numbers separated by commas from the user and send it to the game_of_eights() function. Within the game_of_eights() function, you will provide logic such that: the function returns True if consecutive eights (8) are found in the list; returns False otherwise. the function can handle the edge case where the last element of the list is an 8 without crashing. the function prints out an error message saying 'Error. Please enter only integers.' if the list is found to contain any non-numeric characters. Note that it only prints the error message in such cases, not 'True' or 'False'. Examples: Enter elements of list separated by commas: 2,3,8,8,5 True Enter elements of list separated by commas: 3,4,5,8 False Enter elements of list separated by commas: 2,3,5,8,8,u Error. Please enter only integers.

Answers

Answer 1

Answer:

In Python:

def main():

   n = int(input("List items: "))

   mylist = []

   for i in range(n):

       listitem = input(", ")

       if listitem.isdecimal() == True:

           mylist.append(int(listitem))

       else:

           mylist.append(listitem)

   print(game_of_eights(mylist))

def game_of_eights(mylist):

   retVal = "False"

   intOnly = True

   for i in range(len(mylist)):

       if isinstance(mylist[i],int) == False:

           intOnly=False

           retVal = "Please, enter only integers"

       if(intOnly == True):

           for i in range(len(mylist)-1):

               if mylist[i] == 8 and mylist[i+1]==8:

                   retVal = "True"

                   break

   return retVal

if __name__ == "__main__":

   main()

Explanation:

The main begins here

def main():

This gets the number of list items from the user

   n = int(input("List items: "))

This declares an empty list

   mylist = []

This iterates through the number of list items

   for i in range(n):

This gets input for each list item, separated by comma

       listitem = input(", ")

Checks for string and integer input before inserting item into the list

       if listitem.isdecimal() == True:

           mylist.append(int(listitem))

       else:

           mylist.append(listitem)

This calls the game_of_eights function

   print(game_of_eights(mylist))

The game_of_eights function begins here

def game_of_eights(mylist):

This initializes the return value to false

   retVal = "False"

This initializes a boolean variable to true

   intOnly = True

This following iteration checks if the list contains integers only

   for i in range(len(mylist)):

If no, the boolean variable is set to false and the return value is set to "integer only"

       if isinstance(mylist[i],int) == False:

           intOnly=False

           retVal = "Please, enter only integers"

This is executed if the integer contains only integers

       if(intOnly == True):

Iterate through the list

           for i in range(len(mylist)-1):

If consecutive 8's is found, update the return variable to True

               if mylist[i] == 8 and mylist[i+1]==8:

                   retVal = "True"

                   break

This returns either True, False or Integer only

   return retVal

This calls the main method

if __name__ == "__main__":

   main()


Related Questions

Write the function evens which takes in a queue by reference and changes it to only contain the even elements. That is, if the queue initially contains 3, 6, 1, 7, 8 then after calling odds, the queue will contain 6, 8. Note that the order of the elements in the queue remains the same. For full credit, no additional data structures (queues, stacks, vectors, etc.) should be used. Assume all libraries needed for your implementation have already been included.

Answers

Answer:

Explanation:

The following code is written in Java it goes through the queue that was passed as an argument, loops through it and removes all the odd numbers, leaving only the even numbers in the queue. It does not add any more data structures and finally returns the modified queue when its done.

  public static Queue<Integer> evens(Queue<Integer> queue) {

       int size = queue.size();

       for(int x = 1; x < size+1; x++) {

           if ((queue.peek() % 2) == 0) {

               queue.add(queue.peek());

               queue.remove();

           } else queue.remove();

       }

       return queue;

   }

Select the correct answer.
David gets a new job as a manager with a multinational company. On the first day, he realizes that his team consists of several members from diverse cultural backgrounds. What strategies might David use to promote an appreciation of diversity in his team?
A.
Promote inclusion, where he can encourage members to contribute in discussions.
B.
Create task groups with members of the same culture working together.
C.
Allow members time to adjust to the primary culture of the organization.
D.
Provide training on the primary culture to minority groups only if there are complaints against them.

Answers

C because it’s the smartest thing to do and let the other people get used to each other

Answer:

A.

Explanation:

If we were to go with B, then it would exclude others from different cultures, doing what he is trying to.

If we went with C, then they wouldn't get along very well, because no one likes to be forced into a different religion.

If we went with D, he wants an appreciation, so training some people to change religions if there are complaints, is not going to cut it. Therefore, we have A. Which I do not need to explain.

PLEASE HELP How have phones made us spoiled? How have phones made us unhappy?

Answers

phones have made us spoiled because we have everything at our fingertips. we get what we want when we see something online and we want to get it all we do is ask and most of us receive. phone have made us unhappy mentally and physically because we see how other people have it like richer for instance and we want that and we get sad about weird things because of what we see like other peoples body’s how skinny someone is and how fat someone is it makes us sad because we just want to be like them.

In cell 14, calculate


the profit by


subtracting the


donation from the


streaming revenues.

Answers

Answer:

See Explanation

Explanation:

The question is incomplete as the cells that contains donation and streaming revenues are not given

So, I will make the following assumption:

H4 = Donations

G4 =  Streaming Revenues

So, the profit will be:

Enter the following formula in cell I4

=(G4 - H4)

To get the actual solution in your case, replace G4 and H4 with the proper cell names

2. What is the implication of media killings in the Philippines?​

Answers

Answer:

Throughout the clarification below, the description of the query is mentioned.

Explanation:

In the Philippines, the Implication of media indicates that perhaps the Philippines isn't a safe environment for reporters, and therefore more remains to be improved to change this pattern.But it didn't start underneath Duterte before you could even say that, as well as he didn't order strikes. If he had instructions in which he would criticize, for perhaps a long period presently Ressa had died as one of his other very resolute and influential media commentators.

______________ is a raw fact about a person or an object
Question 1 options:


File


Lookup wizard


Information


Data

Answers

I think its C information. Sowwy if I’m wrong

How many different values can a bit have?
16
2
4.
8

Answers

Answer:

A bit can only have 2 values

what is the correct process for setting up a recurring project for the same client in qbo accountant?

Answers

Answer:

The answer is below

Explanation:

The correct process for setting up a recurring project for the same client in Quickbooks Online Accountant is as follows:

1. Go to Work, then select create a project

2. Select the Repeat button, then set the frequency and duration

3. Formulate the project and save it.

4. Reopen the project

5. And select the Duplicate button for the proportion of times you want it to recur. This includes assigning the interval, day of the recurrence, and end time.

6. Then select Save.

Firstly, invent a separate project, then pick the repeat button on the right of the screen, specify the frequency and duration. Its frequency can indeed be weekly, biweekly, monthly, and so on.

This project's duration must be determined. This step saves the user time when working on a project. Otherwise, the same actions would have to be done again and over, which would be time-consuming and repetitive.New project and click the continue option to start the process of preparing a recurring project for the same client.This second alternative is not the best method to create a recurring project for the same client. Based on the phase, the initiatives can be generated as many times as necessary.

Therefore, the answer is "first choice".

Learn more:

brainly.com/question/24356450

Do any of these algorithms (Random Allocation, Round-Robin, Weighted Round-Robin, Round-Robin DNS Load Balancing, and Least Connections) compromise security?

Answers

Answer:

yes and

Explanation:

why do you need to know about a buildings security are you going to rob it ???

Look at the following assignment statements:

word1 = "rain"
word2 = "bow"

What is the correct way to concatenate the strings?

1 newWord = word1 == word2

2 newWord = word1 + word2

3 newWord = word1 * word2

4 newWord = word1 - word2

Answers

Answer: number 2 is the correct way to do it

Explanation:

Answer:

2 newWord = word1 + word2

Explanation:

Complete the function favoriteFlower(). Note that the program will not run as is because the function is incomplete. The purpose of the function is to determine if the given flower is in the top three of my favorite flowers. The starter file defines a list of favorite flowers that is ordered most favorite to least favorite. Please pass the flower name and the flower list as arguments in the function. The expected output is:

Answers

Answer:

What Language? Once you respond with a comment, I will be happy to write the code for you. I write code 24/7 (Because I have nothing better to do), so I will wait for you to comment. Also is there any pre-existing code?

Explanation:

An expression that returns a value is known as a​

Answers

Answer:

In computer programming, a return statement causes execution to leave the current subroutine and resume at the point in the code immediately after the instruction which called the subroutine, known as its return address. The return address is saved by the calling routine, today usually on the process's call stack or in a register. Return statements in many languages allow a function to specify a return value to be passed back to the code that called the function.

An expression that returns a value is known as a​ function. Check more about function  below.

What is a function?

A function is often seen as a kind of expression or rule, or law that often tells more about a relationship.

Conclusively, a function is known to often returns a value back to the instruction that is known also to be the function. This is regarded as the differences that exist between a method and a function.

Learn more about function  from

https://brainly.com/question/20476366

Arrange the computers in the order fastest to slowest: Minicomputer, Supercomputer, Personal Computer and Mainframe.

Answers

Answer:

supercomputer, mainframe, personal computer, minicomputer

Explanation:

1 #include 2 3 int max2(int x, int y) { 4 int result = y; 5 if (x > y) { 6 result = x; 7 } 8 return result; 9 } 10 11 int max3(int x, int y, int z) { 12 return max2(max2(x,y),z); 13 } 14 15 int main() { 16 int a = 5, b = 7, c = 3; 17 18 printf("%d\n",max3(a, b, c)); 19 20 printf("\n\n"); 21 return 0; 22 } What number is printed when the program is run?

Answers

Answer:

7

Explanation:

#include <stdio.h>

int max2(int x, int y) {

   int result = y;

   if (x > y) {

       result = x;

   }

   return result;

}

int max3(int x, int y, int z) {

   return max2(max2(x,y),z);

}

int main() {

   int a = 5, b = 7, c = 3;

   printf("%d",max3(a, b, c));

   printf("");

   return 0;

}

Hi, first of all, next time you post the question, it would be nice to copy and paste like above. This will help us to read the code easily. Thanks for your cooperation.

We start from the main function:

The variables are initialized → a = 5, b = 7, c = 3

max3 function is called with previous variables and the result is printed → printf("%d",max3(a, b, c));

We go to the max3 function:

It takes 3 integers as parameters and returns the result of → max2(max2(x,y),z)

Note that max2 function is called two times here (One call is in another call actually. That is why we need to first evaluate the inner one and use the result of that as first parameter for the outer call)

We go to the max2 function:

It takes 2 integers as parameters. If the first one is greater than the second one, it returns first one. Otherwise, it returns the second one.

First we deal with the inner call. max2(x,y) is max2(5,7) and the it returns 7.

Now, we need to take care the outer call max2(7, z) is max2(7, 3) and it returns 7 again.

Thus, the program prints 7.

Other Questions
A square has a radius of 10 ft. Find the area of the square name 5 kids who helped the world what are the characteristics of Adolf Hitler What is meant by the order of operations? 2/7 of 49fractions I tried looking this question up online.. didn't show, same with brainly. plz help asap! Will give BRAINLIEST.2. How did resistance help enslaved people? Tsunami waves are caused by earthquakes in the ocean floor. As the waves approach the shore, they usually grow in height. When this occurs, which aspect of the wave is changing?A. amplitudeB. directionC. frequencyD. speedE. wavelength A hot piece of copper was dropped into 155 g of water at 23.6 C and 2,100 J of energy was transferred to the water. What is the final temperature of the water? who stood against the 9066 executive order and said it was wrong 1.Eleanor Roosevelt2.Franklin Roosevelt 3.Harry Truman Which inequality represents all possible solutions of - 4n Dont get confused! The terms immigrant and emigrant can refer to the same person. An easy way to remember it is to look at the first letters of the words. An emigrant exits and an immigrant moves into. If a German woman left her home in Berlin, she emigrated from Germany. If she settled in London, she immigrated to England. A migrant is a person who moves but might not be planning a permanent relocation.Chani left Israel and moved to France when she was 18. Chani is anA. emigrant from Israel and an immigrant to France.B. immigrant to Israel and an emigrant from France.C. immigrant to Israel and France.D. emigrant from Israel and France. A right rectangular prism has a square base and a volume of 225 cubic centimeters. The height, h, of the prism is 9 centimeters. Find the area of the base, B. A. B. C. D. Choose Yes or No to tell whether the Addition Property of Inequality can be used to solve each statement.1. w 4 > 102. 12 20x3. 7y10 5.5 4. 3.25 < x 9.75 4. A square has a perimeter of 28 units, anared of 49 units, and sides that are eitherhorizontal or vertical. The vertices are alllocated in the same quadrant where the xvalue is negative. What are the possiblecoordinates of the square? Please help me out! And please show your work! Type of poetry that tells a story and has characters, plot, setting, and conflict. write a letter to your father telling him to pay your school fees in 350 words Please help??!Which of the following uses repeating vowel sounds?1.The cold, soulless vacuum of space2. Cool, blue, moonlit room3. If loneliness is a disease, love is the cure4. Windy, whooshing weather Sometimes at night I can feel them, the pictures, like ants, crawling on my skin is an example of what figurative language? A total of 76 students responded to a survey about transportation to school. Of the girls surveyed, 22 walk to school and 29 get a ride. Of the 25 boys surveyed, 9 get a ride to school. Construct a two-way frequency table to display the data. Drag the numbers into the boxes. Each number may be used once, more than once, or not at all.