O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic Functions with Python

The following sections cover how Python deals with the raw material of programming: numbers and text.

Numbers

Python can serve as a simple calculator. The syntax it uses is nearly identical to that used for writing spreadsheet formulas. For novices who've created spreadsheets, all of this will seem familiar. The same is true for programmers who've worked with any language that uses an algebraic syntax, such as Pascal, Fortran, Basic, C, or Java.

In Python, you enter a mathematical formula (called an expression) just as you do with spreadsheets, and you're given a resulting value. In programming terms, an expression is a Python statement that returns a value. That value is printed to the console.

Python's expression ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required