Exercise 3.5. (Pythons Arithmetic Operators )
1. Ensure you have viewed the video (associated with this exercise) at this link >>
2. List all the arithmetic operators that can be used in Python with a brief description of each.
3. For each of the following Python statements indicate which is an operand and which an operator.
w = a + b
x = c ** d
y = e // f
z = g % h
w = a + b
x = c ** d
y = e // f
z = g % h
4. For the program below write down the expected output to the Visual Display Unit. Check your answer by copying the code, pasting it into your Python editor and running the program.
Exercise 3.5. Example 1
5. Write a program that asks the user to enter two integers. Have the program output the two integers and the result when the first number entered is raised to the power of the second number entered.
6. Write a program that asks the user to enter two integers. Have the program output how many times the second number can be divided into the first number. For example if the first number entered was 23 and the second number entered was 4 the program should report 5 times (i.e. the fractional bit is ignored). You are required to implement this program using the floor operator.
7. A 1 is always the remainder whenever an odd integer is divided by 2. Write a computer program that asks the user to enter an integer (odd or even) and have it report whether the integer entered is odd. You are required to implement this program using the modulus operator and an if ... Selection construct.
8. A 0 is always the remainder whenever an even integer is divided by 2. Write a computer program that asks the use to enter an integer (odd or even) and have it report whether the integer entered is odd or even. You are required to implement this program using the modulus operator and an if ... else ... Selection construct.
END Next Exercise >>