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
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.
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.
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 >>