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 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
USING PYTHON Build a dataset of the XNOR function with 2 inputs with about 50 to 75 samples. Build a classification model using NN and SVM (LinearSVC kernel) using the scikit-learn library. Calculate the accuracy in both cases and also print the confusion matrix. Please capture your observations on the results and any comments you may have.
9. (a) Find a parametrization for the line segment from the point (-1, 2) to the point (3,-2). given (b) Find the length of the line segment using techniques learned in chapter 11. (Note: No credit will for using the Pythagorean theorem to find the length).