









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










CSSE 120—Rose Hulman Institute of Technology
During session 13, we’ll be doing Tic Tac Toe in pairs. Sometime before you leave today, please find a partner and write both of your usernames next to each other on the sheet that will be passed around
This will allow us to create an SVN repository for each pair.
Can we write a function that exchanges the values of its two parameters? In Eclipse checkout the project named Session11 from your SVN repository Study the code in the module mutatingParameters.py but don’t run it Together, observe what happens as we trace its execution in the debugger
Q
How do functions send information back?
Return statements Mutating parameters Value of actual parameter must be a mutable object State of the mutable object is changed The actual parameter itself is NOT changed since it refers to the same object Parameter is still passed by value
Q
Interactive loops
Sentinel loops
File loops
post-test loops
"loop and a half"
Q
Open module averageUserCount.py and execute it together
When does the loop terminate?
Is this the best way to make the user enter input?
Why? Why not?
Open module averageSentinel.py and study the code then execute it together
User signals end of data by a special "sentinel“ value
Note that the sentinel value is not used in calculations
Q
What if negative numbers are legitimate values?
Open module averageOtherSentinel.py and study the code Execute it together What is the sentinel?
Again note: sentinel value is not used in calculations.
Display a window that contains a circle and a message saying "Click inside Circle".
Whenever the user clicks outside the circle, display "You missed!"
If the user clicks inside the circle, display "Bull's eye!". Then pause and close the window.
Implement together in module clickInsideCircle.py
Define function listAndMax() in module listMax.py that Prompts the user to enter numbers, one at a time Uses a blank line (
Define function main() in module listMax.py that Calls listAndMax() Prints the list of numbers entered Prints the maximum value of the list of numbers Q