Flowcharts, Pseudocode and Python
Quiz 6
Selection Structures


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

    If x < y Then
        print y - x
    Else
        print x - y
    Endif
    

    5
    3
    2
    -2

  2. What will be printed for the following pseudocode if x = 8, y = 4 and op = 2:

    If op == 1 Then
        print x * y
    Else
        print x / y
    Endif
    

    2
    32
    8
    4

  3. What will the value of y be if x = 10:

    If x > 5 Then
        y = x + 15
    Else
        y = x - 15
    Endif
    

    5
    15
    20
    25

  4. What will the value of y be if x = 5:

    If x > 5 Then
        y = x + 15
    Else
        y = x - 15
    Endif
    

    5
    15
    -10
    25

  5. What will the value of bonus be if sales = 5000:

    If sales > 1000 Then
        bonus = 50
    Else
        bonus = 10
    Endif
    

    10
    50
    60
    40

  6. What will the value of bonus be if sales = 500:

    If sales > 1000 Then
        bonus = 50
    Else
        bonus = 10
    Endif
    

    10
    50
    60
    40

  7. What will the value of bonus be if sales = 1000:

    If sales > 1000 Then
        bonus = 50
    Else
        bonus = 10
    Endif
    

    10
    50
    60
    40

  8. What will be printed if x = 10:

    If x == 10 Then
        print "Equal to 10"
    Else
        print "Not equal to 10"
    Endif
    

    Not equal to 10
    Equal to 10
    Equal to 20
    None of the above

  9. What will be printed if x = 20:

    If x == 10 Then
        print "Equal to 10"
    Else
        print "Not equal to 10"
    Endif
    

    Not equal to 10
    Equal to 10
    Equal to 20
    None of the above

  10. What will be printed if x = 10 and y = 20:

    If x > y Then
        print "x is greater than y"
    Else
        print "y is greater than or equal to x"
    Endif
    

    y is greater than x
    y is greater than or equal to x
    x s greater than y
    x is equal to y