IT 116: Introduction to Scripting
Quiz 3 Answers

  1. What are the only values that a boolean expression can have?
    True and False
  2. Write the Python boolean literals.
    True and False
  3. Write the boolean expression that is true if the value of the variable number_1 is greater than or equal to value of the variable number_2.
    number_1 >= number_2
  4. Write an if/elif/else statement that prints "Positive" if the value of the variable numb is greater than 0, and prints "Negative" if it is less than 0 and print "Zero" otherwise.
    if numb > 0:
        print("Positive")
    elif numb < 0:
        print("Negative")
    else:
        print("Zero")
  5. If you typed the following in the Python interactive mode, what would the result be?
    5 != 6
    True
  6. Write a Python statement that evaluates to True if the variable whose name is num has a value greater than 0 and less than 10.
    num > 0  and num < 10
  7. What is the data type of the variable whose name is value_good that is created by the following statement?
    value_good = num > 0
    boolean
  8. In the loop below, what happens each time the boolean expression after the keyword while evaluates to true?
    while num < 10:
    	num = num + 1
    the value of num increases by 1
  9. When does a while loop stop?
    when the  boolean expression after the keyword while becomes false
  10. If you typed the following in the Python interactive mode, what would the result be?
    True and False
    False