Start a Python shell. Type 1 + 2 and then hit return. Python evaluates this expression, prints the result, and then prints another prompt. * is the multiplication operator, and ** is theexponentiation operator. Experiment by entering different expressions and recording what is printed by the Python interpreter. What happens if you use the / operator? Are the results what you expect? Explain.
Having done this a few times before I had a pretty good idea what would happen. I suppose the idea is to first of all teach how a coder can use the interactive prompt to test things out, experiment, and just play. Secondly it leads to a few revelations about how math works in Python, specifically what happens when you divide integers as opposed to floats. Info below:

No comments:
Post a Comment