Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

I. Learning to Program > 2. Calculations and Variables

Chapter 2. Calculations and Variables

Now that you have Python installed and know how to start the Python shell, you’re ready to do something with it. We’ll begin with some simple calculations and then move on to variables. Variables are a way of storing things in a computer program, and they can help you write useful programs.

Calculating with Python

Normally, when asked to find the product of two numbers like 8 × 3.57, you would use a calculator or a pencil and paper. Well, how about using the Python shell to perform your calculation? Let’s try it.

Start the Python shell by double-clicking the IDLE icon on your desktop or, if you’re using Ubuntu, by clicking the IDLE icon in the Applications menu. At the prompt, enter this equation:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint