Flowcharts, Pseudocode and Python
Quiz 7
Nested If-Then-Else and Case Statements


Answer questions 1, 2 and 3 for the pseudocode below:

If x > y Then
    If x > z Then
        print  "x is the largest number"
    Else	 
        print  "z is the largest number"
    EndIf
Else
    If y > z Then
        print  "y is the largest number"
    Else	 
        print  "z is the largest number"
    EndIf
EndIf

  1. What will be printed for the following values if x = 5, y = 3, z = 8:

    x is the largest number
    y is the largest number
    z is the largest number

  2. What will be printed for the following values if x = 5, y = 10, z = 2:

    x is the largest number
    y is the largest number
    z is the largest number

  3. What will be printed for the following values if x = 15, y = 5, z = 10:

    x is the largest number
    y is the largest number
    z is the largest number

    Answer questions 4, 5, 6 and 7 for the pseudocode below:

    If score < 60 Then
    	print "Try very hard!"
    Else If score < 70 Then
        print "Try hard!"
    Else If score < 80 Then
        print "Good!"
    Else If score < 90 Then
        print "Very Good!"
    Else If score <= 100 Then
        print "Excellent!"
    Else 
        print "Invalid score!"
    EndIf
    

  4. What grade will be printed if the score is 75?

    Try very hard!
    Excellent!
    Good!
    Very Good!

  5. What grade will be printed if the score is 85?

    Try very hard!
    Excellent!
    Good!
    Very Good!

  6. What grade will be printed if the score is 90?

    Try very hard!
    Excellent!
    Good!
    Very Good!

  7. What grade will be printed if the score is 60?

    Try very hard!
    Excellent!
    Good!
    Try hard!

    Answer questions 8, 9 and 10 for the pseudocode below:

    Start
        Case of operation:
            Case 'A': answer = n1 + n2
                print answer
                break
            Case 'S': answer = n1 - n2
                print answer
                break
            Case 'M': answer = n1 * n2
                print answer
                break
            Case 'D': answer = n1 / n2
                print answer
                break
            Case '%': answer = n1 % n2
                print answer
                break
    	    Default: print "ERROR"
        EndCase
    End
    

  8. What grade will be printed if the operation is "M" and n1 = 10 and n2 = 5

    15
    5
    2
    50

  9. What grade will be printed if the operation is "%" and n1 = 10 and n2 = 4

    14
    2
    40
    6

  10. What grade will be printed if the operation is "S" and n1 = 10 and n2 = 5

    15
    5
    2
    50