SlideShare a Scribd company logo
1plo
Python – Dictionary and Loops
Mahalakshmi Arulalan
maharulalan@gmail.com
Sets
>>> thisset = {"apple", "banana", "cherry"}
print(thisset)
>>> thisset.add("orange")
>>> thisset.update(["orange", "mango",
"grapes"])
>>> thisset.copy() //Returns a copy of the set
>>> thisset.discard("banana") // Remove the
specified item
>>> discard() Remove the specified item
>>> thisset.add("orange")
thisset = {"apple", "banana", "cherry"}
>>> thisset.update(["orange", "mango",
"grapes"])
print(thisset)
String
name = 'Arul'
name[0]
>>>'A'
myname = 'Arul' + 'alan'
>>> 'Arulalan'
name = 'This is python string'
name.split(' ')
>>>['This','is','python','string']
comma = 'Shrini,Arul,Suresh'
comma.split(',')
>>> ['Shrini','Arul','Suresh']
split
li = ['a','b','c','d']
s = '-'
new = s.join(li)
>>> a-b-c-d
new.split('-')
>>>['a','b','c','d']
join
'small'.upper()
>>>'SMALL'
'BIG'.lower()
>>> 'big'
'mIxEd'.swapcase()
>>>'MiXwD'
Dictionary
menu = {
“idly” : 2.50,
“dosai” : 10.00,
“coffee” : 5.00,
“ice_cream” : 5.00,
100 : “Hundred”
}
menu[“idly”]
2.50
menu[100]
Hundred
Loop
for i in range(1, 5):
print i
print 'The for loop is over'
for i in ["apple", "banana", "cherry"]:
print i
print 'The for loop is over'
for i in range(1, 5):
for j in range (10,20):
print i,j
print 'The for loop is over'
number = 23
running = True
while running :
guess = int(raw_input('Enter an integer : '))
if guess == number :
print 'Congratulations, you guessed it.'
running = False
elif guess < number :
print 'No, it is a little higher than that.'
else:
print 'No, it is a little lower than that.'
print 'Done'
number = 23
while True :
guess = int(raw_input('Enter an integer : '))
if guess == number :
print 'Congratulations, you guessed it.'
break
elif guess < number :
print 'No, it is a little higher than that.'
else:
print 'No, it is a little lower than that.'
print 'Done'
Single Line if, for loop
End of the Day three.

More Related Content

What's hot

บทที่6 update&delete
บทที่6 update&deleteบทที่6 update&delete
บทที่6 update&delete
Palm Unnop
 
Magicke metody v Pythonu
Magicke metody v PythonuMagicke metody v Pythonu
Magicke metody v Pythonu
Jirka Vejrazka
 
Clustering com numpy e cython
Clustering com numpy e cythonClustering com numpy e cython
Clustering com numpy e cython
Anderson Dantas
 
Python data structures
Python data structuresPython data structures
Python data structures
Harry Potter
 

What's hot (14)

บทที่6 update&delete
บทที่6 update&deleteบทที่6 update&delete
บทที่6 update&delete
 
Magicke metody v Pythonu
Magicke metody v PythonuMagicke metody v Pythonu
Magicke metody v Pythonu
 
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
 
{:from => 'Java', :to => 'Ruby'}
{:from => 'Java', :to => 'Ruby'}{:from => 'Java', :to => 'Ruby'}
{:from => 'Java', :to => 'Ruby'}
 
Clustering com numpy e cython
Clustering com numpy e cythonClustering com numpy e cython
Clustering com numpy e cython
 
Python - Lecture 3
Python - Lecture 3Python - Lecture 3
Python - Lecture 3
 
Chap 3php array part 3
Chap 3php array part 3Chap 3php array part 3
Chap 3php array part 3
 
Python data structures
Python data structuresPython data structures
Python data structures
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
FITC CoffeeScript 101
FITC CoffeeScript 101FITC CoffeeScript 101
FITC CoffeeScript 101
 
Begin with Python
Begin with PythonBegin with Python
Begin with Python
 
Association Rule Mining with R
Association Rule Mining with RAssociation Rule Mining with R
Association Rule Mining with R
 
The Ring programming language version 1.5.1 book - Part 50 of 180
The Ring programming language version 1.5.1 book - Part 50 of 180The Ring programming language version 1.5.1 book - Part 50 of 180
The Ring programming language version 1.5.1 book - Part 50 of 180
 

More from MAHALAKSHMI P

Sex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touch
Sex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touchSex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touch
Sex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touch
MAHALAKSHMI P
 

More from MAHALAKSHMI P (13)

Python an-intro youtube-livestream-day4
Python an-intro youtube-livestream-day4Python an-intro youtube-livestream-day4
Python an-intro youtube-livestream-day4
 
Python an-intro youtube-livestream-day2
Python an-intro youtube-livestream-day2Python an-intro youtube-livestream-day2
Python an-intro youtube-livestream-day2
 
Python an-intro youtube-livestream-day1
Python an-intro youtube-livestream-day1Python an-intro youtube-livestream-day1
Python an-intro youtube-livestream-day1
 
double linked list
double linked listdouble linked list
double linked list
 
linked list operations in data structures
linked list operations in data structureslinked list operations in data structures
linked list operations in data structures
 
singly linked_list
singly linked_listsingly linked_list
singly linked_list
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
arrays in data structures
arrays in data structuresarrays in data structures
arrays in data structures
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Data structures- introduction1
Data structures-  introduction1Data structures-  introduction1
Data structures- introduction1
 
Python_in_Detail
Python_in_DetailPython_in_Detail
Python_in_Detail
 
Sex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touch
Sex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touchSex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touch
Sex education,பாலியல் கல்வி ,paaliyal kalvi,good touch bad touch
 
Seminar on sunday
Seminar on sundaySeminar on sunday
Seminar on sunday
 

Recently uploaded

Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 

Python an-intro youtube-livestream-day3

  • 1. 1plo Python – Dictionary and Loops Mahalakshmi Arulalan maharulalan@gmail.com
  • 3. >>> thisset = {"apple", "banana", "cherry"} print(thisset) >>> thisset.add("orange") >>> thisset.update(["orange", "mango", "grapes"]) >>> thisset.copy() //Returns a copy of the set >>> thisset.discard("banana") // Remove the specified item
  • 4. >>> discard() Remove the specified item >>> thisset.add("orange") thisset = {"apple", "banana", "cherry"} >>> thisset.update(["orange", "mango", "grapes"]) print(thisset)
  • 6. name = 'Arul' name[0] >>>'A' myname = 'Arul' + 'alan' >>> 'Arulalan'
  • 7. name = 'This is python string' name.split(' ') >>>['This','is','python','string'] comma = 'Shrini,Arul,Suresh' comma.split(',') >>> ['Shrini','Arul','Suresh'] split
  • 8. li = ['a','b','c','d'] s = '-' new = s.join(li) >>> a-b-c-d new.split('-') >>>['a','b','c','d'] join
  • 11. menu = { “idly” : 2.50, “dosai” : 10.00, “coffee” : 5.00, “ice_cream” : 5.00, 100 : “Hundred” } menu[“idly”] 2.50 menu[100] Hundred
  • 12. Loop
  • 13. for i in range(1, 5): print i print 'The for loop is over'
  • 14. for i in ["apple", "banana", "cherry"]: print i print 'The for loop is over'
  • 15. for i in range(1, 5): for j in range (10,20): print i,j print 'The for loop is over'
  • 16. number = 23 running = True while running : guess = int(raw_input('Enter an integer : ')) if guess == number : print 'Congratulations, you guessed it.' running = False elif guess < number : print 'No, it is a little higher than that.' else: print 'No, it is a little lower than that.' print 'Done'
  • 17. number = 23 while True : guess = int(raw_input('Enter an integer : ')) if guess == number : print 'Congratulations, you guessed it.' break elif guess < number : print 'No, it is a little higher than that.' else: print 'No, it is a little lower than that.' print 'Done'
  • 18. Single Line if, for loop
  • 19. End of the Day three.