PythonByteSize
  • Home
  • Video Index
    • 1. The Basics
    • 2. Python Program Structures
    • 3. Python Operators
    • 4. Python Functions
    • 5. Introduction to Classes and Objects
    • 6. Python Strings
    • 7. User Defined Functions
    • 8. Classes and Objects
    • 9. Python Dictionaries
    • 10. Python tkinter
    • 11. Python Lists
    • 12. Python Namespaces
    • 13. Turtle Graphics
    • 14. Python Tips
  • Exercise Index
    • 1. The Basics Exercises
    • 2. Python Program Structures Exercises
    • 3. Python Operators Exercises
    • 4. Python Functions Exercises
  • Educators
  • Donate
  • Contact
  • Computing Topics
  • Mathematics
  • About

Exercise 3.1 [Pythons Relational Operators (making decisions) ]


1. Ensure you have viewed the video (associated with this exercise) at this link >> 

2. If you saw the following appropriately placed in a Python program which parts would be referred to as an operand and which as an operator?

​var_1 > var_2
 

3. Consider the computer program below. It is a nonsense program meaning it doesn't implement any algorithm it is just to test your understanding of relational operators. By reading the program (i.e. do not executed it to get the answers) write down on paper the output you would expect from the program.
 
You can check your own answer by copying the code and pasting it into your Python editor, and then executing the code.
Exercise 3.1 Example 1

    

4. Write a computer program using an appropriate relational operator and selection construct to implement the following specification.

Specification

Arrange for a computer program to read in two integers from the user.
Use an if ... else ... Selection construct and an appropriate relational operator to print out one of the following to the Visual Display Unit based on the integers entered:
The integers entered have different values.
The integers entered have the same value.



5. Implement the specification above again. This time use a different relational operator but the same if ... else ... Selection construct.

END    Next Exercise >>

Please consider donating to help with the costs incurred in developing this website.             Donate >>