python: build a random line segment in 2-space
# module to plt the graph
import matplotlib.pyplot as plt
# module to generate the random x,slope,y-intercept
import random
x,y=[],[]
# slope
slope=random.random()
# intercept
intercept=random.randint(1,100)
for i in range(5):
# x-coordinates
x.append(random.randint(1,100))
# y-coordinates
y.append(x[i]*slope+intercept)
# plot the graph
plt.plot(x,y)
# display the graph
plt.show()

python program A line segment in one dimension is defined by an ordered pair of coordinates representing the left and right boundaries of the segment. Write a class Segment that implements the interface below, which includes testing whether a point is in a segment, and whether two segments overlap. Note that the constructor should raise an appropriate exception if it receives invalid input (left end is on the right of the right end). • __init__(): constructor that takes one or...
python
after you solve it add a decision to prevent the program from
dividing by zero if the line is vertical.
8. Line Segment Information. This program allows the user to draw a line segment and then displays some graphical and textual information about the line segment. Input: Two mouse clicks for the end points of the line segment. Output: Draw the midpoint of the segment in cyan. Draw the line. Print the length and the slope of the line....
4. A point, A, is chosen at random with uniform distribution on a line segment of length L. A second point, B, is chosen randomly, independently of the first one. Find the probability that B is closer to A than to either of the two endpoints of the line segment.
A point is chosen at random on a line segment of length 12. Find the probability that the ratio of the shorter to the longer segment is less than 3/20.
Using python build the most simple game of rock papers scissors possible. Do not use random or def function. If the user enters anything except rock/ROCK, paper/PAPER, scissors/SCISSORS, tell the user that is not proper input.
Challenge 1: How can you relate a point, a line segment, a square, and a cube? Challenge 2: How can you relate a point, a line segment, a circle, and a sphere? Hint: start with the smallest of these, and think about how you could build up to the next one, and then the next one..
equation for the line segment that joins (2,0,0) to (6,2,-2) 3) Find a vector
equation for the line segment that joins (2,0,0) to (6,2,-2) 3) Find a vector
Python: 1) Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline() print(line) _____________________ print("Error") What should be placed in the blank so that the program will print Error instead of crashing if an exception occurs while opening or reading from the file? Group of answer choices a- except RuntimeError : b- except EnvironmentError : c- except IOError : d- except IndexError : 2) Consider the following code segment: line = "hello world!" parts = line.split()...
The address space of a process contains a stack segment, a heap segment, a .bss segment, a .data segment and a .txt segment. Where are the following stored? a) Dynamic data allocated by malloc() b) An initialized external static variable c) An integer variable declared as static but not initialized within a function
returns a list containing the x- and y-coordinates of the midpoint of the line segment determined by those two points, using decimal division (here is where there is a difference between versions of python). Round the values to the nearest tenth. Name your function getMidpoint(x1, y1, x2, y2). For example, >>>getMidpoint(1, 3, 5.7 ,7) should return the midpoint of the line segment whose endpoints are (1, 3) and (