Skip to content

Commit

Permalink
newfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhayanithi committed Oct 9, 2019
1 parent c0b001c commit 37e4fc7
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 12.tuples.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#tuples are similar to arrays but cannot br changed
thistuple = ("apple", "banana", "cherry")
thistuple2=(2,3,4)
print(thistuple)
print(thistuple[2])
print(thistuple[-2])
print(thistuple[0:2])

print('apple' in thistuple)
print(len(thistuple))

#returns a new tuple
print(thistuple+thistuple2)
for value in thistuple:
print(value)
28 changes: 28 additions & 0 deletions 13.sets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
s={1,2,2,3,2,4}
#add new elements
s.add(5)
print(s)

for value in s:
print(value)
#adding more elements
s.update([3,2,3,2,2,6,7,8])
print(s)

#removing elements
s.remove(2)
s.discard(2)

#remove last element
s.pop()
#clears the set
s.clear()
#delete the set
del s

s1={1,2}
s2={3,4}

s3=s1.union(s2)
s3.update(s1)
print(s3)
19 changes: 19 additions & 0 deletions 14.dictionaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
d={
'name':'ajin',
'age':21
}

print(d['name'])

for key in d:
print(key)

for value in d.values():
print(value)

for key,value in d.items():
print(key)
print(value)

d.pop('age')
print(d)
4 changes: 4 additions & 0 deletions 15.functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def addNumbers(x,y):
return x+y

print(addNumbers(3,2))
3 changes: 3 additions & 0 deletions 16.lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sum=lambda x,y:print(x+y)

sum(2,2)
11 changes: 11 additions & 0 deletions 17.class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Rectangle:
def __init__(self,length,breadth):
self.length=length
self.breadth=breadth

def findarea(self):
print(self.length*self.breadth)


r1=Rectangle(2,20)
r1.findarea()

0 comments on commit 37e4fc7

Please sign in to comment.