06.0 Python‎ > ‎Python Projects‎ > ‎Dice Project‎ > ‎

Dice v1-rollDice()

Objectives

The student will learn to refactor their first version of the Dice program by including the following new concepts:
  • create a programmer defined function that returns a value
  • adding documentation with  """docstring"""
The student will practice the following familiar concepts:
  • learning objectives from the previous Dice program 

Program Description

Note:  Modifying a program structure without changing the program's external functionality is call refactoring.

BEFORE MODIFYING YOUR PROGRAM, CREATE A COPY OF IT TO KEEP
  • Refactor (modify) a copy of your Dice program. 
  • Create (define) a function called rollDie() that will return a new value for the value of the die each time it is called. 
  • Add proper documentation for the new function 
  • update the previous program documentation.
After you have modified your program correctly, copy and paste the code in the the visualizer at pythontutor. Watch the code and its results as you step through the execution of the program.
Now do the same for your first Dice program. Compare how flow through the program differs.


Comments