Note for CS 150 at UA-Programming I-(1)
Note for CS 150 at UA-Programming I-(1)
Popular in Course
Popular in Department
This 2 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Alabama - Tuscaloosa taught by a professor in Fall. Since its upload, it has received 14 views.
Reviews for Note for CS 150 at UA-Programming I-(1)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
CS 150 Project 1 Revision Date Monday September 16 2013 Introduction Those who aim at nothing hit it with remarkable accuracy In this project we ll simulate darts being thrown at a circular target We want to know how close the dart hits to the center of the target In this case we ll use a unit circle r l and we ll put the circular target on a square board So our initial target would look like this We ll use Python s random number generator to give us x and y values to simulate throwing darts at the target Then we ll calculate the distance of the dart from the origin or center of the circle using the distance formula based on the Pythagorean right K triangle Look it up on the net Ifthe distance is less than or equal to one it is inside the circle but a distance greater than one would be outside of the circle If it is outside the circle is it still on the board We don t want to make dart holes in the wall There will be ve darts thrown and you ll get the x and y coordinates for where it hits by calling random random The program will rst check to see if the dart hit the target and then check to see if it is still on the board It should count the darts in each category and print out the number in each group at the end of the program Where to Start Create a directory called proj ect 1 off your cs1 50 directory Use vim to create your program le named project 1 py The rst thing that should go into your program is a comment section where you put your name the class the project and the date due You should also write a quick description of this program It should look something like this 4 My Name CS 150 Project 1 Due September 28 2013 Let 5 play darts iiii t t t t 4 Next you should import the random module and then begin your mai 11 function Use the random number generator to generate 5 values for x and y Since we don t know how to do loops yet we ll repeat this call 10 times for 5 values of x and 5 values of y For each point check to see if it is inside the circle If it is print In the target x 7 y 7 If it is not in the target print Outside the target x 7 y 7 Fill in the values for x and y for each dart Once the program has generated all the requested points print a count of the number of darts inside the circle outside the circle and off the board Challenges 0 For any two darts are they colinear with the origin or center of the circle 0 For any dart is it exactly on the circle s edge Is it within 1 of the edge between 099 and 101 inclusive 0 Read ahead and gure out how to use a loop to through more than 5 darts with less code 0 Add a couple of smaller concentric circles and see if any darts hit inside the smaller circles In a real darts game they would score more points Submission Instructions Make sure you are in your pro j ect 1 directory and do an 1 5 command You should see something like this projectl py Extra les are OK as long as you are in the correct directory Submissions from the wrong directory that include many extra les will be penalized And you may be penalized if you submit les unrelated to this project Submit your le like this submit csl 50 YYY proj ectl Remember to replace YYY with your instructors last name and a time if your instructor teaches two sections Due Date The due date for this assignment can be found on the class schedule
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'