Python Slope i don’t know how to start python assignment

  python
  1. Write a fruitful function, calculateSlope, that will calculate the slope of the line between two points in the Cartesian coordinate plane given the two points. The function should return the slope. The function should perform no console input or output. Use the following function header:

def calculateSlope(x1, y1, x2, y2):

Recall the formula for slope is: m = frac{y_2 – y_1} {x_2 – x_1}

Write a fruitful function, findYIntercept, that will return the y-intercept of the line connecting two points in the Cartesian coordinate plane. Use the following function header:

def findYIntercept(x1, y1, x2, y2):
The function should perform no console input or output.

Recall the following:
Formula for y-intercept is: b = y_1 – mx_1

Write a non-fruitful function, findLineEquation, that will find the equation of the line connecting two points in the Cartesian coordinate plane. Use the following function header:

def findLineEquation(x1, y1, x2, y2):
The function should display the two points and the equation of the line between the two points to the screen.

Recall the following:
Equation of a line is: y = mx + b

The function should only call the calculateSlope function if the slope of the line is defined. The function should perform no console input. Use 1 decimal place when displaying the equation of the line to the user. Leading coefficients of 1 and -1 should not be displayed to the user. If the y-intercept is 0, the 0 should not be displayed to the user. If the y-intercept is a negative number, the equation of the line generated should not have two signs in a row. Please see the note below to see what the expected lines are to displayed as.

Include driver code for the following points:
(1, -1) and (1, -10)
(6, 1) and (2, 5)
(-5, -3) and (8, 10)
(1, 3) and (2, 3)
(1, -1) and (2, -2)
(1, 1) and (2, 2)
(2, 4) and (3, 6)
(1, -4) and (2, -6)

Note:
The equation of the line between (1, -1) and (1, -10) should be displayed to the user as x = 1.0.
The equation of the line between (6, 1) and (2, 5) should be displayed to the user as y = -x + 7.0.
The equation of the line between (-5, -3) and (8, 10) should be displayed to the user as y = x + 2.0.
The equation of the line between (1, 3) and (2, 3) should be displayed to the user as y = 3.0.
The equation of the line between (1, -1) and (2, -2) should be displayed to the user as y = -x.
The equation of the line between (1, 1) and (2, 2) should be displayed to the user as y = x.
The equation of the line between (2, 4) and (3, 6) should be displayed to the user as y = 2.0x.
The equation of the line between (1, -4) and (2, -6) should be displayed to the user as y = -2.0x – 2.0.

Write a function, call it isInsideCircle that will determine if a point lies inside or outside of a circle. The function should have a return type of bool. Include code in the "main" part of the program that will read the following information from the user:
A circle, as follows:
The (x,y) coordinates of the circle’s center (integers are fine).
The radius of the circle (a real number).
A point (x,y).
Given this information, determine if the point entered by the user lies inside or outside of the circle. Display a message indicating whether the point is inside or outside the circle.

Use the following function header:

def isInsideCircle(centerX, centerY, radius, pointX, pointY):
The function should perform no console input or output.

Source: Python Questions

LEAVE A COMMENT