Chapter 3 : Overview of Java Language

exmple 3.1, page no. 25

In [2]:
print "Python is better than Java."
Python is better than Java.

example 3.2, page no. 27

In [4]:
import math

x = 5
y = math.sqrt(x)
print "y = ", round(y,5)
y =  2.23607

example 3.3, page no. 28

In [6]:
"""
Note: there is no need of another class here, as in Python there is no need of main class.
"""

class Room:
    length = 0.0
    breadth = 0.0
    def getdata(self, a, b):
        self.length = a
        self.breadth = b

room1 = Room()
room1.getdata(14.0, 10.0)
area = room1.length*room1.breadth
print "Area = ", area
Area =  140.0

example 3.4, page no. 35

In [7]:
print "Hellow!"
print "Welcome to the world of Python."
print "Let us learn Python."
Hellow!
Welcome to the world of Python.
Let us learn Python.
In [8]:
"""
Command line arguments cannot be taken from IPython Notebook.
Hence, example 3.5 is ignored.
"""
Out[8]:
'\nCommand line arguments cannot be taken from IPython Notebook.\nHence, example 3.5 is ignored.\n'