-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dhayanithi
committed
Oct 9, 2019
1 parent
c0b001c
commit 37e4fc7
Showing
6 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sum=lambda x,y:print(x+y) | ||
|
||
sum(2,2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |