[Tutor] Python problem

ThreeBlindQuarks threesomequarks at proton.me
Mon Oct 10 14:00:13 EDT 2022


With so much to choose from, I am considering doing the shortest question #1 which will be neglected by others.

To be fair, questions 2 to 4 build on each other and this looks like a single program. That makes me wonder if the missing question helps set up the rest.

I await replies showing some attempts to work these problemd or ca reply that contains actual questions of a tutoring nature ant not the actual assignment the teacher gave. I want to know if they figured out question one on their own.

Sent from Proton Mail mobile

-------- Original Message --------
On Oct 10, 2022, 12:00 PM, Dennis Lee Bieber wrote:

> On Sun, 9 Oct 2022 23:42:04 +0000, "Moore, Colleen"  declaimed the following: >Hi, I figured I could post a question here that I wasn't sure how to solve. Below are the problems: > And what is your question... You've posted three assignments (at least, to me they are as they each specify a /separate/ program, and not just three phases within a single program). You have not stated where you are stuck, nor shown any code. We do not "do homework" for you -- you must make the attempt, show us the code and any error messages (DO NOT ATTACH SCREEN GRABS -- they get stripped; cut&paste the TEXT into a message), and we may guide you into correct understanding of the construct giving problems... >Question 2. Write a Python program to create a list of 1000 random points. These points must be objects of the Point class. The X and Y coordinates of these points must be random float between a range and any arbitrary range will be fine. (Hint: random.uniform can be used to generate a random floating point value between any two given numbers.) > Hmmm, what was "Question 1"? The above assumes you know how to perform basic Python logic... IE: loop over a section of code for 1000 times; declaring simple Classes and creating instances of that class; accumulate the 1000 points into some structure. Actually, given the separate program phrasing -- said "accumulation" doesn't even have to be internal; you could write out the coordinates to a file which the following two programs read... Granted, unless one is using pickle or related to save the points, one loses the entire Class construct -- generating a "Point" just involves generating two random values and writing them out as a line to some text file. If you haven't learned these simple tasks, you may want to ask yourself: Do I belong in this course? >Question 3. After you finish the above, write a program to print out the number of points that fall in the left half of the area. If a point is exactly on the middle of the area, you are free to decide to either count it in the left half, or right half. Please note in your program how which is the case. > And as mentioned above, this assumes some means of passing the "Points" of the first assignment into the second. Without using pickle, that means reading each line of the file, parsing out two coordinates, and recreating the Point instance... All to simply look at the X coordinate and determine if it is left or right of the midpoint range (which has to somehow be carried over from the first assignment -- maybe written as the first row of the data file). This time, instead of a definite loop (first assignment: 1000 points), one likely has an indefinite loop (loop until end of file), reading a line, determining if it is left/right (and why bother with creating a Point instance when you throw it away on the next iteration) summing how many are on each side. >Question 4. Write a Python program to draw the points for the above question. Points counted as falling into the left are rendered in darkgrey and right in lightgrey. Submit both your code and a screenshot of the plotting result. This is the only assignment where a Points class might be of use, as most plotting packages want ALL the data in one chunk. You are basically repeating the second assignment, but this time rather than counting left/right, you may be accumulating the points into some structure that can be fed to the plotting package (and that may not want "Points" per se, but two vectors: one of only X coordinates, and the other of the Y coordinates). BUT! WHAT TYPE OF PLOT IS REQUIRED? Simple histogram? (In this case, you ARE duplicating the previous assignment -- the only thing changing is that rather than printing numeric results you are creating a two column histogram with the counts. Side by side scatter-plots (dots for each point, taking into account the left/right split, and using Y coordinate for height of the dot in the plot)? Scatter-plot with connecting lines showing the order the points were created? -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ _______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list