A) What does the program for this flowchart do?
- Finish the flowchart.
- Write the full program.
Flowchart maker: https://app.diagrams.net/
B) Next answer, explain, and/or write code snippets:
- What is a pseudorandom number?
- In the game of “guess a number”, when does the user exit the program?
- In the game of “guess a number”, how many loops are needed? Explain.
- How do you use the range function to print the integers from 34 through 41 inclusive?
- How do you add all the integers from 34 through 41 inclusive? Show code.
- Write the code to prompt the user for an integer, N. Your program will display a square pattern of asterisks N by N
- Write the code to print all even integers from 36 through 12 inclusive.
- Write the code for a while loop to prompt the user if he or she wants to continue to input more integers.
C) The following questions are related to this flowchart:
- What is the oval shape used for?
- What is the code for each instruction in the flowchart?
- Draw the flowchart to find the two digits in the middle of a 4-digit integer.
D) Write the code to calculate and display:
“ 1 1” “ 2 4” “ 3 9” “ 4 16” “ 5 25”
E) What does this program do?
import random for i in range( 1, 22 ): print ("%6d" % ( random.randrange( 1, 7 ) ), end = ""), if i % 3 == 0: # print newline every ?? rolls print("")
F) What does this program do?
nterms = int(input("Enter a number ")) # first two terms n1, n2 = 0, 1 count = 0 if nterms <= 0: print("Enter a positive number ") elif nterms == 1: print(n1) else: while count < nterms: print(n1) nth = n1 + n2 # update values n1 = n2 n2 = nth count += 1
What is the output?
G) Two more
- What structure can be used to repeat a block of statements when the termination of the loop is not known? Explain your answer.
- What structure can be used to repeat a block of statements when the termination of the loop is known? Explain your answer.