Files

1.2 KiB
Raw Permalink Blame History

id, source_exercise_id, title, section, source_path, source_repo, source_commit, student_visible_solution, has_private_solution, skip
id source_exercise_id title section source_path source_repo source_commit student_visible_solution has_private_solution skip
practical-python-1.1 1.1 Using Python as a Calculator 1.1 Python 01_Introduction/01_Python.md https://github.com/dabeaz-course/practical-python 93dca856b41c61a0a0f85ae334116e4c125629ea false false false

Exercise 1.1: Using Python as a Calculator

Source: Practical Python Programming, 01_Introduction/01_Python.md.

Exercise 1.1: Using Python as a Calculator

On your machine, start Python and use it as a calculator to solve the following problem.

Lucky Larry bought 75 shares of Google stock at a price of $235.14 per share. Today, shares of Google are priced at $711.25. Using Python’s interactive mode as a calculator, figure out how much profit Larry would make if he sold all of his shares.

>>> (711.25 - 235.14) * 75
35708.25
>>>

Pro-tip: Use the underscore (_) variable to use the result of the last calculation. For example, how much profit does Larry make after his evil broker takes their 20% cut?

>>> _ * 0.80
28566.600000000002
>>>

关联来源