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(): |
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 | |
#Advertencia | |
#El programa funciona al quinto intento. | |
#Demasiada recursividad. | |
def IngresarP(): | |
p=raw_input("Ingrese una palabra: ") | |
if len(p)!=0: | |
return p |
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(a): | |
a=False | |
def Maestro(): | |
archivo=open("Maestro","a") | |
rut=raw_input("Rut: ") | |
Nombre=raw_input("Nombre: ") | |
Direccion=raw_input("Direccion: ") | |
Genero=raw_input("Genero: ") |
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 AgregarRegistros(): | |
archivo=open("Notas.txt","a") | |
nom=raw_input("Ingrese Nombre: ") | |
sir=raw_input("Ingrese Dirección: ") | |
tele=raw_input("Ingrese Telefono: ") | |
registro=str(nom)+';'+str(sir)+';'+str(tele)+'\n' | |
archivo.write(Registro) | |
def Lectura(): | |
archivo=open("Notas.txt","r") |
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
##1. Realizar la sumatoria desde i=0 hasta n del factorial de x partido el factorial de i | |
def factorial(x): | |
if x>1 and x<2: | |
return 1; | |
else: | |
if x<0: | |
return 0 | |
return x*factorial(x-1) | |
def sumatoria(n): |
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(): | |
a=False | |
while a!=True: | |
x=raw_input("Ingresa un numero: ") | |
if x.isdigit(): | |
a=True | |
return x | |
else: | |
print "Lo que ingresaste no es un numero. Intenta nuevamente." |