Постови

Приказују се постови за март, 2020

Python location of max number in matrix

(The Location class) Design a class named Location for locating a maximal value and its location in a two-dimensional list. The class contains the public data fields row, column, and maxValue that store the maximal value and its indexes in a two-dimensional list, with row and column as int types and maxValue as a float type. Write the following method that returns the location of the largest element in a two-dimensional list. def findLocation( self ): The return value is an instance of Location. Write a test program that prompts the user to enter a two-dimensional list and displays the location of the largest element in the list.  class Location:     def __init__ ( self , row = 0 , column = 0 , maxValue = 0 ):         self .row = row         self .column = column         self .maxValue = maxValue         self ....

Python intersection of two lines

(Geometry: intersection) Suppose two line segments intersect. The two endpoints for the first line segment are (x1, y1) and (x2, y2) and for the second line segment are (x3, y3) and (x4, y4). Write a program that prompts the user to enter these four endpoints and displays the intersecting point. class Intersection():     def __init__ ( self , x1, y1, x2, y2, x3, y3, x4, y4, a = 1 , b = 1 , c = 1 , d = 1 , e = 1 , f = 1 ):         self .__x1 = x1         self .__x2 = x2         self .__x3 = x3         self .__x4 = x4         self .__y1 = y1         self .__y2 = y2         self .__y3 = y3         self .__y4 = y4         self .__a = a   ...