Saturday, August 6, 2011

Python Standard Input to Python script

#!/usr/bin/python

#Now we will see the Concatination in Python

print "Balasubramaniam", "Natarajan"

#If we want it to print without space

print "Balasubramaniam"+"Natarajan"

#If we want python to print Bala fivetimes

print "Bala\n"*3

# We can get the values from STDIN using the raw_input (for strings) or input (for integer) function.

flname = raw_input("What is your name?")

print "The name you have typed here is :", flname

rupees = input("How much is a liter of water?")

print "One Liter of water cost : RS", rupees

print "So 10 Liters of water would cost : RS", rupees*10

*******************************************************************************
bala@bala-laptop:~/python$ python 5STDIN.py
Balasubramaniam Natarajan
BalasubramaniamNatarajan
Bala
Bala
Bala

What is your name?Bala
The name you have typed here is : Bala
How much is a liter of water?20
One Liter of water cost : RS 20
So 10 Liters of water would cost : RS 200
bala@bala-laptop:~/python$


No comments:

Post a Comment