Stack is LIFO data structure (Last In First Out) where the last element entered in stack will be the last one to be out of stack. It has three operations: push() : used to insert an element in stack, pop() : used to delete an element from the stack, top() : used to return the top of the stack i.e. the newest member of the stack. All these operations will take place at the top.
<u>Explanation:</u>
Now, looking at the program, x and y are initialized the values of 2 and 3 respectively. The stack pushes 8 onto the stack making it the first member of the stack. Then the value of x which is 2 is pushed onto the stack. Next, (x+5) = (2+5) = 7 is pushed onto the stack.
Pop() is used to delete hence 7 is popped out from the stack. top() is assigned to y which is 2 in this case and again 2 is popped out from the stack. Now, (x+y) = (2+2) = 4 is pushed onto the stack. And the top() is assigned to x which is 4. 4 is again popped out from the stack. Hence the value of x is 4.
Answer:
This is python, I don't know what type of programming language you are learning.
import random
# Enter your code here
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
total = 0
while True:
if dice1 == 1 and dice2 == 1:
total += 1
print("Rolled: " + str(dice1) + " " + str(dice2))
break
else:
total += 1
print("Rolled: " + str(dice1) + " " + str(dice2))
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
print("It took you "+ str(total) + " rolls to get snake eyes.")
Explanation:
Answer:
Print the manual in a loose leaf binder so even small changes can be replaced
Explanation:
Procedure manual is the document that contains the business policies and strategies. These strategies can be changed time to time in the interest of company.
As these policies or procedures changes, it is necessary to communicate with all employees. To communicate this updated information to all employees it is necessary to print all that pages, where the changes have been made to replace them in the current manual. If we print whole manual it may increase the cost of printing. To reduce printing cost and wastage of pages only print those particular pages that have been changed. This will help to communicate to the existing employees as well as to newly hired employees.
Answer:
The Internet
Explanation:
Why? The internet has done twice if not thrice what the printing press has done. The printing press allowed for dissemination of information and knowledge to the population through its mechanical movable printing capability and speed of book publishing. However its reach was highly limited by the physical attributes of the machines and having to transfer books and papers in spreading them to certain destinations. This limitation has been eliminated by the internet as one is able to receive a book written today in seconds and not physically but through electronic means. In other words, information need not be transferred physically, also accessbility and cost of getting information has been highly improved with the internet.