x % y
x + y
x - y
x * y
x / y
x // y
x**y
round(x, y)
addition
subtraction
multiplication
division
integer division
remainder from integer division
round x to y decimal places
indices (powers)
Remember to use information provided by the user, you MUST convert the string [from input()] to either integer [int()] or float [float()] format.
num1 = input("Enter a number: ")
num2 = input("Enter another number: ")
division = num1 / num2 #This will produce an error
num1 = float(input("Enter a number: "))
num2 = float(input("Enter another number: "))
division = num1 / num2 #This will run correctly
import math
math.pi
math.sqrt(num)
import math
pi = math.pi
root = math.sqrt(num)
from math import pi, sqrt
pi = math.pi
root = math.sqrt(num)
For more information about the math module go to:
from math import *
Display the following message:
If the user enters 1, then it should ask them for the length of one of its sides and display the area. If they select 2, it should ask for the base and height of the triangle and display the area. If they type in anything else, it should give them a suitable error message.
1) Square
2) Triangle
Enter a number: