Create a file called hw04
Store it in your CS100/hw
folder.
You are to write 4 functions on the topics of functions, loops, and conditionals.
You should put all 4 functions in the file you created and submit that to Moodle.
Positive Integer (i.e 182), Positive Decimal (i.e. 8.031), Zero, Negative Integer (i.e. -94), Negative Decimal (i.e. -456.12)
After you write the function, call it with each of those numbers above to demonstrate that the program works correctly.
# Called with 4 Called with 5 Called with 5 Called with 7 Called with 30
In your program, call this function with the parameter 5 three times, and the parameter 10 once.
“All three values are the same”, “Two of the values are equal”, “All three values are different and the middle value is:” (provide the middle value)
checkThree(7,7,7)
All three values are the same
checkThree(8,3,8)
Two of the values are equal
checkThree(0,0,5)
Two of the values are equal
checkThree(2,9,12)
All three values are different and the middle value is: 9
checkThree(4,1,9)
All three values are different and the middle value is: 4
checkThree(2,20,17)
All three values are different and the middle value is: 17
Call this function with the six example inputs here.
Before drawing the dots, the program should draw two boxes on the canvas. (See the picture below). The function should then draw the random dots. If the dot is in either box, it should be RED, if it is not in the either box, it should be BLUE. Finally, the program should print the number of dots in the first box, the number of dots in the second box, and how many dots were not in either box.
Call this function with 100 dots.
In order to receive any credit, your program must run without syntax errors in Thonny. Thonny reports syntax errors in red in the shell area; if Thonny outputs an error, your code isn’t usable. Code that doesn’t run is just text - it’s not a program. It’s an important part of programming and problem solving to come up with a solution that can be shared with others.
Your program doesn’t have to be perfect to be eligible for credit! It’s okay to have some semantic errors. Semantic errors don’t stop your program from running, but they cause your program to produce an unexpected or incorrect result. For example, if your program is supposed to calculate the sum of the first 100 numbers, but instead it accidentally calculates the sum of the first 101 numbers, that would be a semantic error. Semantic errors may result in partial credit depending on how close your solution is.
Make sure that all of the code that you wrote for this assignment has been included in your .py file. Make sure that you have named in hw04