http://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_Python/Dict-7&feed=atom&action=history
Curso de Programación en Python/Dict-7 - Historial de revisiones
2024-03-28T14:03:31Z
Historial de revisiones para esta página en el wiki
MediaWiki 1.32.1
http://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_Python/Dict-7&diff=6790&oldid=prev
Rrc en 20:35 24 nov 2014
2014-11-24T20:35:08Z
<p></p>
<p><b>Página nueva</b></p><div>__NOTOC__<br />
* [[:#Dict-7 | Dict-7.py]]<br />
** [[:#Resultado | Resultado]]<br />
<br />
== Dict-7.py ==<br />
<br />
<syntaxhighlight lang="python" line="GESHI_FANCY_LINE_NUMBERS"><br />
<br />
#!/usr/bin/python3<br />
#-*-coding: utf-8 -*-<br />
<br />
Gastos = { "Departamento" : 3500, "Coche" : 750, "Utilidades" : 4500 }<br />
<br />
# Convert to list of tuples<br />
GastosItems = Gastos.items()<br />
<br />
print( "El tuple GastosItems:", GastosItems, "\n" )<br />
# Loop and display tuple items<br />
for GastosItem in GastosItems:<br />
print( "Gasto:", GastosItem[0] )<br />
print( "Costo:", GastosItem[1] )<br />
print( "" )<br />
<br />
</syntaxhighlight><br />
<br />
<br />
=== Resultado ===<br />
<br />
<pre><br />
[rrc@Llawyr PythonClase]$ ./Dict-7.py <br />
El tuple GastosItems: dict_items([('Coche', 750), ('Departamento', 3500), ('Utilidades', 4500)]) <br />
<br />
Gasto: Coche<br />
Costo: 750<br />
<br />
Gasto: Departamento<br />
Costo: 3500<br />
<br />
Gasto: Utilidades<br />
Costo: 4500<br />
</pre><br />
<br />
[[Category:Programación en Python]]<br />
[[Category:PythonCabal]]<br />
[[Category:CursoPython]]</div>
Rrc