Made a simple straight line calculator, not very useful by itself but it still works.
# Straight line calculatordef both_coordinates(): x1 = int(input(" 1st X co-ordinate ? ")) y1 = int(input(" 1st Y co-ordinate ? ")) x2 = int(input(" 2nd X co-ordinate ? ")) y2 = int(input(" 2nd Y co-ordinate ? ")) m = (y1 - y2 ) / (x1 - x2) c = y1 - m*x1 print(" y = %sx + %s" %(m, c))def one_coordinate_gradient(): x1 = int(input(" 1st X co-ordinate ? ")) y1 = int(input(" 1st Y co-ordinate ? ")) m = int(input(" What is the gradient of the line?")) c = y1 - m*x1 print(" y = %sx + %s" %(m, c))def one_coordinate_yintercept(): x1 = int(input(" 1st X co-ordinate ? ")) y1 = int(input(" 1st Y co-ordinate ? ")) c = int(input(" at what point does the line cross the y axis ?")) m = (c - y1) / x1 print(" y = %sx + %s" %(m, c))while True: num_coords = int(input(" how many co-ordinates do you have")) if num_coords <= 2: if num_coords == 2: both_coordinates() if num_coords == 1: m_c = input("do you have C or M") if m_c == "m": one_coordinate_gradient() if m_c == "c": one_coordinate_yintercept() else: print("you need 2 co-ordinates, gradient or y-intercept to get the formula") True else: print("Error occured try again") True
Only 41 lines.