Adding Randomness and Functions to Python

 This week, I worked on adding certain challenges to the original python code that I created. I worked to expand my current python code skillset to include functions and randomness. Using the resources provided by my professor, I was able to expand my python code. 

I started by trying to create randomness by drawing a circle using different integers which changes the size of the circle every time I run it. So instead of the circle coming out from the same spot every time, it would come out from different areas and allow the circle to be different sizes.

I set the range for the random integers to be between 1 and 10. I did not want to go any larger as it made the pattern too big and go out of the screen space.

I also changed the loop from instead of 12 iterations to be 6 iterations to fit the space. This would mean it would only repeat the process 6 times instead of 12.

In addition, I tried to create a function that stores value of the random integer in x and y. I then printed the value of x and y to show which random integers were used. This would prove the randomness that I created because each time I would run it, different and random integers would be printed on the bottom screen. 

Another aspect I changed was that I expanded screen.setup X coordinate to be 700 pixels in order to accommodate the randomness. This would allow the screen to appear bigger so that the random-sized circle could fit on the screen. 

Please feel free to compare and contrast my original python code to this one! I have attached 2 screenshots to show that I ran it once to show random integers then I ran it again which showed another random set of integers.









Comments

  1. Ayesha,
    You have done some really interesting work here.
    Can you share your Replit so I can poke around with your code?

    ReplyDelete

Post a Comment