You are on page 1of 3

''' Created on Oct 4, 2013 @author: rajendra ''' print('Hello World!!') # Hi this is comment.

x = 2; s = "rajendra"; d='c'; e = str(x)+ (d); #print(s+x); print(e); #assert(1==3); def add(a,b): return a+b; print("Value is:: " +str(add(2,3))); i = 1; ''' for i in range(1,10): if i <= 5: print(str(i)+ ' Smaller or equal then 5 \n'); else: print(str(i)+ ' Larger than 5::\n'); ''' s = "rajendra rana bhat! "; print(len(s)); print(s[2]); print(s[-2]); print(s[0:5]); print('abcdef'[0:9]); print('abcdef'[4:]); a=1;b=2;c=4; print('a'+'b'+'c'); print(s.upper()); print(s.rstrip()); assert ("abcdefg"[4:0]==""); assert ("abcdefg"[0:2]=="ab"); mylist = ['linux',"Window","MAC OS"] print(mylist[0]); print(mylist[-1]); print(mylist[0:9]); mylist.append(a); #print(mylist); print("Following list"); for element in mylist: print(element) mylist = ['linux','linux','window']; mylist=list(set(mylist)); print(mylist);

f = open("C:\\Java Related Stuff\\eclipse\\workspace\\HelloPython\\readmepython. txt","r"); print(f); #for line in f: # print(line.rstrip()); #f.close(); output = open('C:\\Java Related Stuff\\eclipse\\workspace\\HelloPython\\readmepy thonwrite.txt','w'); for line in f: output.write(line.rstrip()+'\n'); f.close(); output.close(); print('DONE'); ss = "I like apple,orange,pies,banana"; jj = "I like nissan,toyata,ford,tata"; list1 = ss.split(","); list2 = jj.split(",") #print(list[2:4]) # -*- coding: UTF-8 -*class Point: def __init__(self, x=0, y=0): self.x = x self.y = y def __str__(self): return "x-value" + str(self.x) + " y-value" + str(self.y) def __add__(self,other): p = Point() p.x = self.x+other.x p.y = self.y+other.y return p p1 = Point(3,4) p2 = Point(2,3) print( p1); print( p1.y); print (p1+p2);

You might also like