--- id: practical-python-1.1 source_exercise_id: "1.1" title: "Using Python as a Calculator" section: "1.1 Python" source_path: "01_Introduction/01_Python.md" source_repo: "https://github.com/dabeaz-course/practical-python" source_commit: "93dca856b41c61a0a0f85ae334116e4c125629ea" student_visible_solution: false has_private_solution: false skip: 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. ```python >>> (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? ```python >>> _ * 0.80 28566.600000000002 >>> ``` ## 关联来源 - [[summaries/01_Python]]