print 'Hello World'
print 'Hello World'
print 'Hello World with cout'
print 'Hello World with cerr'
print 'Hello World with clog'
c=raw_input()
print c
for i in range(255):
if i==26:
continue
print i,chr(i)
import sys
test=raw_input("Enter string: ")
i=0
print "Output string: ",
while True:
if test[i].isspace():
break
else:
sys.stdout.write(test[i])
i+=1
test=raw_input("Enter string: ")
print "Output string:", test
string1="Object-Computing"
string2=" with C++"
len1=len(string1)
len2=len(string2)
for i in range(1,len1):
print string1[:i]
for i in range(len1, 0, -1):
print string1[:i]
print "%s%s" %(string1[:len1], string2[:len2])
print string1+string2
print string1[:6]
MAX_MARKS=600.0
def read(self):
self.__name=raw_input("Enter Name: ")
self.__marks=int(raw_input("Enter Marks Secured: "))
def show(self):
print '{:>10}'.format(self.__name),
print '{:>6}'.format(self.__marks),
print '{0:10.0f}'.format((self.__marks/MAX_MARKS)*100)
class student:
__name=str
__marks=int
read=read
show=show
count=int(raw_input("How many students ? "))
s=[]*count
for i in range(count):
s.append(student())
for i in range(count):
print "Enter Student", i+1, "details..."
s[i].read()
print "Student Report..."
print '{:>3}'.format("R#"),
print '{:>10}'.format("Student"),
print '{:>6}'.format("Marks"),
print '{:>15}'.format("Percentage")
for i in range(count):
print "%3s" %(i+1),
s[i].show()
desig=["CEO", "Manager", "Receptionist", "Clerk", "Peon"]
salary=[10200,5200,2950,950,750]
print "Salary Structure Based on Designation"
print "-------------------------------------"
print '{:>15}'.format('Designation '),
print '{:>15}'.format('Salary (in Rs.)')
print "-------------------------------------"
for i in range(5):
print '{:.>15}'.format(desig[i]),
print '{:*>15}'.format(salary[i])
num=raw_input("Enter any hexadecimal number: ")
print "The input number in decimal = %d" %int(num, 16)
num=raw_input("Enter any hexadecimal number: ")
print "The input number in decimal = %d" %int(num, 16)
x=int(100)
print format(x, '02x'), x
f=122.3434
print f
print '{:.2f}'.format(f)
print "0x%0.4X" %x
print '{:.3e}'.format(f)
f1=123.45
f2=34.65
f3=float(56)
print '{0:6.2f}'.format(f1)
print '{0:6.2f}'.format(f2)
print '{0:6.2f}'.format(f3)
i=raw_input("Enter octal number: ")
print "Its decimal equivalent is: %d" %int(i, 8)
i=int(raw_input("Enter decimal number: "))
print "Its output:", oct(i)
import math
num=int(raw_input("Enter Any Integer Number: "))
print "-----------------------------------------------------"
print '{:>5}'.format("NUM"),
print '{:>10}'.format("SQR"),
print '{:>15}'.format("SQRT"),
print '{:>15}'.format("LOG")
print "-----------------------------------------------------"
for i in range(1, num+1):
print '{:>5}'.format(i),
print '{:>10}'.format(i*i),
print '{:15.3f}'.format(math.sqrt(i)),
print '{:15.4e}'.format(math.log(i))
def sp():
print "",
x=1
y=2
z=3
w=4
print x,
sp(),
print y,
sp(),
print z,
sp(),
print w
def rupee():
print "Rs.",
def dollar():
print "US$",
print "Item Sales in India..."
item1=raw_input("Enter Item Name: ")
cost1=int(raw_input("Cost of Item: "))
print "Item Sales in US..."
item2=raw_input("Enter Item Name: ")
cost2=int(raw_input("Cost of Item: "))
print "Item Cost Statistics..."
print "Item Name:", item1
print "Cost:",
rupee(),
print cost1
print "Item Name:", item2
print "Cost:",
dollar(),
print cost2
def output(self, x):
print '{x:{f}>{w}.{p}f}'.format(x=x,f=self._my_manipulator__fill,w= self._my_manipulator__width, p=self._my_manipulator__precision)
class my_manipulator:
__width=int
__precision=int
__fill=chr
def __init__(self, tw, tp, tf):
self.__width=tw
self.__precision=tp
self.__fill=tf
output=output
def set_float(w, p, f):
return my_manipulator(w, p, f)
f1=123.2734
f2=23.271
f3=16.1673
set_float(10, 3, '*').output(f1)
set_float(9, 2, '^').output(f2)
set_float(8, 3, '#').output(f3)
class POINT:
__x=int
__y=int
def __init__(self):
self.__x=0
self.__y=0
def output(self):
print "(%d,%d)" %(self.__x, self.__y)
def input(self):
self.__x, self.__y=[int(x) for x in raw_input().split()]
p1=POINT()
p2=POINT()
print "Enter two coordinate points (p1, p2):",
p1.input(), p2.input()
print "Coordinate points you entered are:"
p1.output()
p2.output()
num=raw_input("Enter a hexadecimal value: ")
num=int(num, 16)
print "Octal equivalent:", oct(num)
PI=3.14159265
print "The values at different levels of precision are:"
for i in range(1, 6):
print '%0.*f' % (i, PI)