Home
Explore
Submit Search
Upload
Login
Signup
Advertisement
Check these out next
Python Programming Essentials - M11 - Comparison and Logical Operators
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M18 - Modules and Packages
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M25 - os and sys modules
P3 InfoTech Solutions Pvt. Ltd.
Advanced Patterns with io.ReadWriter
Weaveworks
Demonstration on keyword
deepalishinkar1
NativeBoost
ESUG
Python decorators
Alex Su
Decorators in Python
Ben James
1
of
17
Top clipped slide
Python Programming Essentials - M13 - Tuples
Aug. 19, 2014
•
0 likes
4 likes
×
Be the first to like this
Show More
•
1,695 views
views
×
Total views
0
On Slideshare
0
From embeds
0
Number of embeds
0
Report
Technology
Slides from the training on the topic "Python Programming Essentials"
P3 InfoTech Solutions Pvt. Ltd.
Follow
P3 InfoTech Solutions Pvt. Ltd.
Advertisement
Advertisement
Advertisement
Recommended
Python Programming Essentials - M5 - Variables
P3 InfoTech Solutions Pvt. Ltd.
2.4K views
•
28 slides
Python Programming Essentials - M7 - Strings
P3 InfoTech Solutions Pvt. Ltd.
2.2K views
•
23 slides
Python Programming Essentials - M9 - String Formatting
P3 InfoTech Solutions Pvt. Ltd.
1.8K views
•
9 slides
Python Programming Essentials - M17 - Functions
P3 InfoTech Solutions Pvt. Ltd.
1.7K views
•
21 slides
Python Programming Essentials - M6 - Code Blocks and Indentation
P3 InfoTech Solutions Pvt. Ltd.
1.6K views
•
13 slides
Python Programming Essentials - M31 - PEP 8
P3 InfoTech Solutions Pvt. Ltd.
2.1K views
•
29 slides
More Related Content
Slideshows for you
(19)
Python Programming Essentials - M11 - Comparison and Logical Operators
P3 InfoTech Solutions Pvt. Ltd.
•
1.4K views
Python Programming Essentials - M18 - Modules and Packages
P3 InfoTech Solutions Pvt. Ltd.
•
1.9K views
Python Programming Essentials - M25 - os and sys modules
P3 InfoTech Solutions Pvt. Ltd.
•
2.8K views
Advanced Patterns with io.ReadWriter
Weaveworks
•
3.2K views
Demonstration on keyword
deepalishinkar1
•
80 views
NativeBoost
ESUG
•
1.8K views
Python decorators
Alex Su
•
2.1K views
Decorators in Python
Ben James
•
1.7K views
Rust Intro
Arthur Gavkaluk
•
288 views
Decorators Explained: A Powerful Tool That Should Be in Your Python Toolbelt.
Samuel Fortier-Galarneau
•
1.2K views
From Java To Clojure (English version)
Kent Ohashi
•
841 views
Advanced Python, Part 2
Zaar Hai
•
946 views
lab4_php
tutorialsruby
•
344 views
Advanced Python : Decorators
Bhanwar Singh Meena
•
3.1K views
Python decorators
Guillermo Blasco Jiménez
•
1.1K views
SymfonyCon 2017 php7 performances
julien pauli
•
2.8K views
jRuby: The best of both worlds
Christopher Spring
•
2.9K views
Namespaces
zindadili
•
129 views
Locker: distributed consistent locking
Knut Nesheim
•
1.4K views
Similar to Python Programming Essentials - M13 - Tuples
(14)
Hey! There's OCaml in my Rust!
Kel Cecil
•
2.1K views
Perl: Hate it for the Right Reasons
Matt Follett
•
1K views
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Puppet
•
1.4K views
XAML/C# to HTML/JS
Michael Haberman
•
953 views
Improve Your Edge on Machine Learning - Day 1.pptx
CatherineVania1
•
19 views
Powerful and flexible templates with Twig
Michael Peacock
•
980 views
Twig for Drupal @ Frontendunited Amsterdam 2012
Rene Bakx
•
2.9K views
Drupal 8: Theming
drubb
•
2.1K views
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Prof. Wim Van Criekinge
•
4.7K views
Drupal as a framework
Samuel Solís Fuentes
•
598 views
CPSC 131 Homework 2 D e a d l i n e D e a d l i n e .docx
vanesaburnand
•
2 views
Making an Object System with Tcl 8.5
Donal Fellows
•
1.6K views
Bioinformatica p6-bioperl
Prof. Wim Van Criekinge
•
677 views
Download It
webhostingguy
•
1.9K views
Advertisement
More from P3 InfoTech Solutions Pvt. Ltd.
(19)
Python Programming Essentials - M44 - Overview of Web Development
P3 InfoTech Solutions Pvt. Ltd.
•
1.8K views
Python Programming Essentials - M40 - Invoking External Programs
P3 InfoTech Solutions Pvt. Ltd.
•
555 views
Python Programming Essentials - M39 - Unit Testing
P3 InfoTech Solutions Pvt. Ltd.
•
1.3K views
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
P3 InfoTech Solutions Pvt. Ltd.
•
833 views
Python Programming Essentials - M35 - Iterators & Generators
P3 InfoTech Solutions Pvt. Ltd.
•
993 views
Python Programming Essentials - M29 - Python Interpreter and Files
P3 InfoTech Solutions Pvt. Ltd.
•
1.2K views
Python Programming Essentials - M28 - Debugging with pdb
P3 InfoTech Solutions Pvt. Ltd.
•
811 views
Python Programming Essentials - M27 - Logging module
P3 InfoTech Solutions Pvt. Ltd.
•
1.1K views
Python Programming Essentials - M24 - math module
P3 InfoTech Solutions Pvt. Ltd.
•
2.6K views
Python Programming Essentials - M23 - datetime module
P3 InfoTech Solutions Pvt. Ltd.
•
1.4K views
Python Programming Essentials - M22 - File Operations
P3 InfoTech Solutions Pvt. Ltd.
•
1.5K views
Python Programming Essentials - M21 - Exception Handling
P3 InfoTech Solutions Pvt. Ltd.
•
2.1K views
Python Programming Essentials - M20 - Classes and Objects
P3 InfoTech Solutions Pvt. Ltd.
•
2.3K views
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
•
2.8K views
Python Programming Essentials - M15 - References
P3 InfoTech Solutions Pvt. Ltd.
•
336 views
Python Programming Essentials - M14 - Dictionaries
P3 InfoTech Solutions Pvt. Ltd.
•
1.1K views
Python Programming Essentials - M12 - Lists
P3 InfoTech Solutions Pvt. Ltd.
•
2.1K views
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
P3 InfoTech Solutions Pvt. Ltd.
•
716 views
Python Programming Essentials - M8 - String Methods
P3 InfoTech Solutions Pvt. Ltd.
•
1.7K views
Recently uploaded
(20)
Aztec Labs - Digital Pound Consultation Response.pdf
AztecLabs
•
207 views
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
ICS
•
51 views
Python Operators.pptx
M Vishnuvardhan Reddy
•
29 views
COMPUTATIONAL ANALYSIS OF CIS-REGULATORY ELEMENTS AND ASSOCIATED TRANSCRIPTIO...
VartikaRai17
•
34 views
Entiende y mejora tu estrategia B2B con Partner Manager - MuleSoft Madrid Mee...
jorgelebrato
•
33 views
SEARCH-ENGINE-OPTIMIZATION-SEO-BEGINNERS-TOOLS(1).pdf
GeraldNsofor
•
28 views
INoC-21-Types-of-News.pdf
MuzamilKhan739599
•
35 views
Supply Chain Attacks
Lionel Faleiro
•
50 views
HypeOrHero3.pdf
Avi Bar-Zeev
•
35 views
wire-all-the-things-lambda-days-2023.pdf
Eric Torreborre
•
488 views
Streamline Your Integration with Salesforce’s Composite API: A Consultant’s G...
CzechDreamin
•
124 views
Give them what they need: A case study of what retailers can accomplish with ...
BookNet Canada
•
33 views
Building Trust and Competitive Advantage: The Value of Privacy Certifications
TrustArc
•
78 views
Biometric Authentication.pdf
Narudom Roongsiriwong, CISSP
•
230 views
Peering Personal MyNOG-10
MyNOG
•
24 views
Equinix: New Markets, New Frontiers
MyNOG
•
39 views
From Tacoma Narrows to West Seattle…Appsec Lessons from A Century of Pacific...
Adam Shostack
•
129 views
How to Hire Dedicated WordPress Developers in India
Pixlogix Infotech
•
35 views
Harnessing AI and Web3 for Operators
AndyHall865717
•
140 views
Supercharge Salesforce Marketing Cloud: The Ultimate Apps Guide, Cyril Louis ...
CzechDreamin
•
102 views
Advertisement
Python Programming Essentials - M13 - Tuples
http://www.skillbrew.com /SkillbrewTalent brewed by
the industry itself Python Tuples Pavan Verma @YinYangPavan Python Programming Essentials
© SkillBrew http://skillbrew.com What
is a Tuple Tuple is a sequence of items, similar to a list The difference between list and tuple is: tuple is immutable while list is mutable 2
© SkillBrew http://skillbrew.com Tuple
example Lets say we want to represent number of hits on blog on a particular date 3
© SkillBrew http://skillbrew.com Lets
create a tuple Myblog.com 100 20-Oct-2013 4 blog_hits = ['Myblog.com', 50, '20-Oct-2013'] blog_hits = ('Myblog.com', 50, '20-Oct-2013') list tuple
© SkillBrew http://skillbrew.com Packing
a Tuple 5 blog_hits = 'Myblog.com', 50, '20-Oct-2013' print blog_hits ('Myblog.com', 50, '20-Oct-2013')
© SkillBrew http://skillbrew.com Unpacking
a Tuple 6 >> blog_name, hits, date = blog_hits >> print blog_name, hits, date 'Myblog.com' 50 '20-Oct-2013'
© SkillBrew http://skillbrew.com Accessing
Values in Tuples Myblog.com 100 20-Oct-2013 7 >>> blog_hits = ('Myblog.com', 50, '20-Oct-2013') >>> blog_hits[0] Myblog.com >>> blog_hits[2] 20-Oct-2013 0 1 2
© SkillBrew http://skillbrew.com Tuple
with a single element >>> blog_hits = ('Myblog.com') >>> type(blog_hits) <type 'str'> >>> blog_hits = ('Myblog.com', ) >>> type(blog_hits) <type 'tuple'> 8 Must have this comma
© SkillBrew http://skillbrew.com Common
Operations on Tuples 9 Python Expression Results Description len(1, 2, 3) 3 Length (1, 2, 3) + (4, 5, 6) (1, 2, 3, 4, 5, 6) Concatenation a = (1, 2, 3, 4, 5, 6) a[2:5] (3, 4, 5) Slicing
© SkillBrew http://skillbrew.com How
are Tuples different from Lists Apart from syntactical difference ( ) vs [ ], the real difference is that lists are mutable whereas tuples are not Tuples (generally) are sequences of different kinds of stuff, and you deal with the tuple as a coherent unit Lists (generally) are sequences of the same kind of stuff, and you deal with the items individually 10
© SkillBrew http://skillbrew.com Tuples
are Immutable >>> blog_hits[0] = 'yourblog.com' Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> blog_hits[0] = 'yourblog.com' TypeError: 'tuple' object does not support item assignment 11
© SkillBrew http://skillbrew.com Example
of tuple and list usage >>> colors = ['red', 'green', 'blue'] >>> colors = [ ('red', '#FF0000'), ('green', '#00FF00'), ('blue', '#0000FF') ] 12 • tuples are used in Python where a struct would be used in C/C++ • Tuples usually heterogeneous data whereas lists usually contain homogenous data
© SkillBrew http://skillbrew.com Converting
a tuple to list >>> blog_hits = ('Myblog.com', 50, '20-Oct-2013') >>> list(blog_hits) ['Myblog.com', 50, '20-Oct-2013'] 13 Use list() function to convert a tuple to a list
© SkillBrew http://skillbrew.com Use
tuple to return multiple values from functions Tuples are used to return multiple values from a function 14 >>> def points(x): y = 1 - x return x, y >>> points(.5) (0.5, 0.5) >>> t = points(.3) >>> t (0.3, 0.7) >>> t[0] 0.3 >>> t[1] 0.7 >>>
© SkillBrew http://skillbrew.com Summary
What is a tuple Packing/unpacking a tuple Accessing values in tuple Tuple with a single element Tuples are immutable How are tuples different form lists Converting between tuple and list Returning multiple values from functions 15
© SkillBrew http://skillbrew.com References
Tutorial on tuples http://www.tutorialspoint.com/python/python_tuples.htm Basics tuple operation python documentation http://docs.python.org/2/tutorial/datastructures.html#tuples- and-sequences 16
17
Editor's Notes
It is mandatory to have a , in tuple
If you have to represent lets say colors a list would be fine But if you have to represent a color and its code it makes more sense to pack it into a tuple
Advertisement