A tuple is an unchangeable sequence of values.
x=(“Gilberto”,18,”ISC”) #A tuple is written with ()
When you do this you create a tuple with three elements. You can access these elements individually by typing the variable and the then inside brackets directly to the right of the variable type the number of the element to which you are referring.
print (x[o])
>>>Gilberto
Python starts numbering at 0 so Gilberto=0,18=1 and ISC = 2
Packing and Unpacking:
In tuple packing, the values on the left are ‘packed’ together in a tuple:
x=(“Gilberto”,18,”ISC”)
In tuple unpacking, the values in a tuple on the right are ‘unpacked’ into the variables/names on the right:
x=(“Gilberto”,18,”ISC”)
(Name,Age,Studies) = x
print(Name,Age,Studies)
>>>Gilberto 18 ISC
Sources for info. about tuples: Link
#TC1014
#MASTERY24
Gilberto Rogel García
#Mastery08
Python conventions (Zen of Python)
https:/ / www.python.org/ dev/ peps/ pep-0008/
Coding conventions are rules that were created by programers to make people’s life easier when reading a code.
These conventions were created in order to have a better style when programming and that way, make the code easier to understand.
Coding conventions include:
Comments Off on #Mastery08
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #a, #blank, #block, #class, #code, #Comments, #constants, #copyright, #descriptive, #designing, #documentation, #exception, #function, #global, #imports, #indentation, #inline, #introduction, #maximum, #method, #names, #naming, #other, #overriding, #package, #pet, #prescriptive, #public, #references, #source, #string, #tabs, #version, #whitespace, Programming