Showing posts with label Add. Show all posts
Showing posts with label Add. Show all posts

Wednesday, 8 January 2014

String Concatenation in python

You can join two or more strings to form a new string using the concatenation operator +. Here is an example:

>>> "sony" + " biswas" + " nitol"
'sony biswas nitol'

plus (+) sign use for concatenate two or more string

Using Python to Perform Mathematical Computations

Python programs can perform all sorts of mathematical computations and display the result. To display the addition, subtraction, multiplication, and division of two numbers, xand y, use the following code:
print(x + y)
print(x – y)
print(x * y)
print(x / y)

1 # Compute expression
>>> print((150-3.5) + (542-6))
682.5

>>> print((150-3.5) - (542-6))
-389.5

>>> print((150-3.5) * (542-6))
78524.0

>>> print((150-3.5) / (542-6))
0.2733208955223881
>>>