
Patrick B. answered 02/06/21
Math and computer tutor/teacher
import math
import random
#inputs the positive number and output the square root of
# the number correct to 2 digits
x = -1
while float(x)<0 :
x = input("Please input the number :>")
y = round(math.sqrt(float(x)),2)
print(" the square root of " + str(x) + " is " + str(y))
print("\n")
x = random.randint(1,20)
y = random.randint(1,20)
z = int(x) + int(y)
print("the sum of " +str(x) + " and " + str(y) + " is " + str(z))
print("\n")
z = random.randint(1,20)*5
print(" Random Multiple of 5 between 1 and 100 is " +str(z))
print("\n")
A=(5,7,8,10,-1,-2,20,45,55,99,0,23)
print(" max is " + str(max(A)))
print(" min is " + str(min(A)))
x1 =input("Please input x-coordinate of 1st point x1 :>")
y1= input("Please input y-coordinate of 1st point y1 :>")
x2= input("Please input x-coordinate of 2nd point x2 :>")
y2= input("Please input y-coordinate of 2nd point y2 :>")
deltaX = float(x1)-float(x2)
deltaY = float(y1)-float(y2)
DeltaXsqr = math.pow(float(deltaX),2)
DeltaYsqr = math.pow(float(deltaY),2)
D = math.sqrt( float(float(DeltaXsqr) + float(DeltaYsqr)))
print("distance is " + str(D))