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
#Dijkstra | |
#Aplicación del algoritmo visto en clases | |
#0. Validaciones | |
def Validar(): | |
a=input("Valor: ") | |
if a.isdigit(): #Función para corroborar que una línea de caracteres corresponden exclusivamente a números | |
#Es una función bool de verdadero o falso | |
return int(a) |
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
A B 7 | |
A D 5 | |
B C 8 | |
B E 7 | |
D E 15 | |
D F 6 | |
F E 8 | |
F G 11 | |
E G 9 | |
C E 5 |
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
# Dijkstra's algorithm for shortest paths | |
# David Eppstein, UC Irvine, 4 April 2002 | |
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117228 | |
from priodict import priorityDictionary | |
def Dijkstra(G,start,end=None): | |
D = {} # dictionary of final distances | |
P = {} # dictionary of predecessors | |
Q = priorityDictionary() # est.dist. of non-final vert. |
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
def ValidarNombre(dato): | |
a=str(dato) | |
l=len(dato) | |
for i in range(l): | |
if not a[i]>='a' and a[i]<='z' or a[i]>'A' and a[i]<='Z' or a[i]==' ': | |
return False | |
return True | |
def ValidarEdad(dato): | |
a=dato |
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
def TotalConducido(CodigoConductor,txt): | |
horas=0 | |
for linea in txt: | |
dato=linea.split("#") | |
if dato[2]==CodigoConductor: | |
horas=horas+dato[3] | |
return horas | |
def MostrarConductores(txt): | |
for linea in txt: |
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
def Validar(): | |
x=raw_input() | |
if x.isdigit(): | |
return x | |
print "Ingrese un valor numerico." | |
Validar() | |
def listasr(): | |
archivo=open("datos.txt","r") | |
l=[] |
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
#AUTOR : MAURO CASTILLO V. | |
#FECHA : 16 oct 2014 | |
#DESCRIPCION : USO DE ARCHIVOS | |
archivo = open("datos.txt","r") #Para abrir el archivo, ojo, el r es de read para leer | |
sec = input("Ingrese seccion : ") #Numero de seccion para comparar | |
nombre = "seccion"+str(sec)+".txt" #Se crea un archivo con el numero de seccion ingresada | |
seccion = open(nombre,"w") #Se abre el archivo desde 0, ojo que 'w' sirve para abrir un archivo desde 0 | |
#Si quieres agregar mas datos a un archivo creado usa el 'a' en vez del 'w' |
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
import myFunciones.py | |
myFunciones.main() |
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
def Validar(): | |
x=raw_input("Valor: ") | |
if x.isdigit(): | |
return x | |
print "Caracter ingresado no valido. Ingrese numero." | |
Validar() | |
#Escribir un programa que permita crear dos listas de palabras | |
def Crear(): | |
print "Ingrese largo: " |
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
import random | |
def CrearLista(): | |
largo=raw_input("Ingrese largo: ") | |
lista=[] | |
for i in range(largo): | |
elem=raw_input("Ingrese elementos") | |
lista[i]=[elem] | |
def CrearListasRandom(): |