Questions
python Write a Loop class. The contents of a loop object are represented internally as a...

python

Write a Loop class. The contents of a loop object are represented internally as a simple python list with the following additional instance variables:

loop - a python list containing the elements of the loop list

head - which stores the index of the first element of the loop list

current - which stores the index of the last element of the loop list

size - which stores how many actual elements are in the loop

max - which stores the max number of elements that can be in a loop

Note that current and head will be the same when the list is empty, and when the list contains a single element.

And methods:

__init__(self, max) - which constructs an empty loop object;

__str__(self) - which returns a string representing the loop object as described below;

add(element) - which adds the element to the end of the loop (i.e. at the position of current + 1)

empty() - which says whether there are any elements in the loop;

count() - which says how many elements currently are in the loop;

delete() - which returns the first item from the loop (i.e. at the position of head) and removes it from the loop;

max() - returns the max number of elements allowed in the loop.

__init__ initializes the empty locations in the loop list to None. Assume that max is always greater than the number of elements to be in the loop at any one time. When an element is being added to an empty loop, it always goes into the first location (index 0) in the loop list and head and current are reset to 0.

If an attempt is made to delete() from an empty loop then delete()  returns None. When an element is deleted from the loop its value is changed to None. Remember, your code needs to properly maintain the correct values of loop, head, current and size.

__str__ formats the loop object data as follows:

<max> <size> <head> <current> <loop list>

For example, after:

x = Loop(4)

x.add(1)

x.add(3)

x.delete()

print(x)

"print(x)" prints out:

4 1 1 1 [None, 3, None, None]

For example:

Test Result
x = Loop(5)
print(x)
5 0 0 0 [None, None, None, None, None]
x = Loop(5)
x.add(3)
print(x)
5 1 0 0 [3, None, None, None, None]
x = Loop(3)
x.add(3)
x.add(2)
print(x)
3 2 0 1 [3, 2, None]
x = Loop(3)
x.add(3)
x.add(2)
x.delete()
print(x)
3 1 1 1 [None, 2, None]
x = Loop(3)
x.add(2)
x.add(5)
x.add(3)
x.delete()
x.add(7)
print(x)
3 3 1 0 [7, 5, 3]                     

In: Computer Science

Consider the complement of the event before computing its probability. If two 12​-sided dice are​ rolled,...

Consider the complement of the event before computing its probability.

If two 12​-sided dice are​ rolled, find the probability that neither die shows a ten.

(Hint: There are 144 possible results from rolling two 12​-sided ​dice.)

The probability is __. (Simplify your​ answer.)

In: Statistics and Probability

Consider the probability that less than 15 out of 156 people have been in a car accident. Assume the probability that a given person has been in a car accident is 13%.


Consider the probability that less than 15 out of 156 people have been in a car accident. Assume the probability that a given person has been in a car accident is 13%. 

Approximate the probability using the normal distribution. Round your answer to four decimal places. 

In: Statistics and Probability

You were told that the mean score on a statistics exam is 75 with the scores...

You were told that the mean score on a statistics exam is 75 with the scores normally distributed. In addition, you know the probability of a score between 55 and 60 is 4.41% and that the probability of a score greater than 90 is 6.68%. What is the probability of a score between 55 and 95?

In: Statistics and Probability

Consider the probability that greater than 99 out of 157 people have not been in a...

Consider the probability that greater than 99 out of 157 people have not been in a car accident. Assume the probability that a given person has not been in a car accident is 55%.

Approximate the probability using the normal distribution. Round your answer to four decimal places.

In: Statistics and Probability

a. Two dice are rolled; find the probability that the sum of the two numbers is...

a. Two dice are rolled; find the probability that the sum of the two numbers is 7.

b. If one card is drawn from a standard deck, find the probability of getting a spade card or a Queen.

c. A couple has 3 children, find the probability that exactly one are girls.

In: Statistics and Probability

Consider the probability that no less than 92 out of 157 registered voters will vote in...

Consider the probability that no less than 92 out of 157 registered voters will vote in the presidential election. Assume the probability that a given registered voter will vote in the presidential election is 64%

Approximate the probability using the normal distribution. Round your answer to four decimal places.

In: Statistics and Probability

THIS IS A DECISION ANALYSIS MAKING CLASS (HEALTHCARE ADMINISTRATION) Discuss why probability is so important within...

THIS IS A DECISION ANALYSIS MAKING CLASS (HEALTHCARE ADMINISTRATION)

Discuss why probability is so important within the health care decision analysis. Provide specific areas of understanding, for Classical, Empirical, Subjective and Axiomatic Probability. Why are these Probability used in the health care decision analysis?

In: Math

Consider a binomial experiment with 16 trials and probability 0.60 of success on a single trial....

Consider a binomial experiment with 16 trials and probability 0.60 of success on a single trial.

(a) Use the binomial distribution to find the probability of exactly 10 successes.

(b) Use the normal distribution to approximate the probability of exactly 10 successes.

(c) Compare the results of parts (a) and (b).

In: Math

A standard deck of cards contains 52 cards. One card is selected from the deck. (a)...

A standard deck of cards contains 52 cards. One card is selected from the deck. (a) Compute the probability of randomly selecting a jack or ace. ​(b) Compute the probability of randomly selecting a jack or ace or nine. ​(c) Compute the probability of randomly selecting a king or diamond.

In: Math