示例#1
0
def main():
    while True:
        print("")
        print("_____________________________")
        print("|                           |")
        print("|      --INSERT TEXT--      |")
        print("|___________________________|")
        print("")
        directorio()
        archivo = encuentra_archivo()
        texto = input("Introduzca texto a insertar: ")
        font = fuente()
        cuenta = 1
        desv1 = OKI(input("Desviación x del centro: "))
        desv2 = OKI(input("Desviación y del centro: "))
        color = color_texto()
        for i in os.listdir():
            if i.startswith(archivo):
                try:
                    inserta_texto(i, font, texto, cuenta, color, desv1, desv2)
                except:
                    print(
                        "LA OPERACIÓN NO PUDO LLEVARSE A CABO PARA EL ARCHIVO ",
                        i)
        conti = ns(input("¿Desea continuar?: "))
        if conti == "n":
            break
        subprocess.call(["cmd.exe", "/C", "cls"])
示例#2
0
def enum(opcions):
    for i, opcion in enumerate(opcions):
        print(i, opcion)
    eleccion = OKI(input("Introduzca número correspondiente a su opción: "))
    while eleccion > (len(opcions) - 1):
        eleccion = OKI(
            input("Introduzca indice válido correspondiente a su opción: "))
    assert eleccion in range(len(opcions))
    tex_elec = opcions[eleccion]
    return tex_elec
示例#3
0
def mn_valido(n):#FUNCION VALIDA PARA MINUTOS Y SEGUNDOS
    while True:
        if n==("m"):
            mn=OKI(input("Introduce minuto: "))
        else:
            mn=OKI(input("Introduce segundo: "))
        if mn<0 or mn>=60:
            pass
        else:
            break
    return mn
示例#4
0
def color_texto():
    col = ns(input("¿Definir color del texto?: "))
    if col == "s":
        rojo = color_numero(OKI(input("Introduce valor para ROJO: ")))
        verde = color_numero(OKI(input("Introduce valor para VERDE: ")))
        azul = color_numero(OKI(input("Introduce valor para AZUL: ")))
        opac = color_numero(OKI(input("Introduce valor de opacidad: ")))
        tup_color = (rojo, verde, azul, opac)
    else:
        tup_color = (255, 255, 255, 255)
    return tup_color
示例#5
0
def hora_valida():
    while True:
        h=OKI(input("Introduce hora: "))
        if h<0 or h>=24:
            pass
        else:
            break
    return h
示例#6
0
def DecimalAHexadecimal():
    decimal = OKI(input("Introduzca número: "))
    hexadecimal = ""
    while decimal != 0:
        rem = CambiarDigitos(decimal % 16)
        hexadecimal = str(rem) + hexadecimal
        decimal = int(decimal / 16)
    print("Resultado: " + hexadecimal)
示例#7
0
def dia_valido(año,mes,dia):
    d1=date(año,mes,1)
    if mes==12:
        d2=date(año+1,1,1)
    else:
        d2=date(año,mes+1,1)
    diferencia=d2-d1
    while dia>diferencia.days or dia<1:
        dia=OKI(input("Número de dia no valido: "))
    return dia
示例#8
0
def validate(p):
    global total
    global i
    global parti
    if i == 6:
        i = 0
    while not int(p) in range(0, 5):
        p = OKI(input("INTRODUZCA VALOR ENTRE 0 Y 4: "))
    total += p
    parti[i] += p
    i += 1
示例#9
0
def fuente():
    while True:
        fuen = input("Establezca tipo de fuente: ")
        fuen = (fuen.lower()) + ".ttf"
        tama = OKI(input("Establezca tamaño de la fuente: "))
        try:
            fnt = ImageFont.truetype(fuen, tama)
            return fnt
            break
        except:
            print("NO SE PUDO ESTABLECER LA FUENTE ESPECIFICADA")
示例#10
0
def desamb(tem):
    posibles_temas = wikipedia.search(tem)
    if len(posibles_temas)>0:
        print("********DESAMBIGUACIÓN********")
        print(tem,"puede referirse a:")
        for i,posible_tema in enumerate(posibles_temas):
            print(i,posible_tema)
        eleccion = OKI(input("Introduzca número correspondiente a su opción: "))
        if eleccion <= (len(posibles_temas)-1):
            assert eleccion in range(len(posibles_temas))
            habla(posibles_temas[eleccion])
        else:
            print("VALOR DE ENTRADA INCORRECTO")
示例#11
0
            print("NO SE ENCONTRÓ EL ARCHIVO", gif_name)
            gif_name = busca()
        name, ext = os.path.splitext(gif_name)
        try:
            im = Image.open(gif_name)
            print("\nDimensiones: ", im.size[0], "x", im.size[1])
            print("")
            break
        except:
            print("\nNo se pudo abrir el archivo", gif_name)
            os.remove(gif_name)

    corte = ns(input("¿Desea realizar cortes sobre los frames?: "))

    if corte == "s":
        dato_iz = OKI(input("Introduce dato izquierdo: "))
        dato_sup = OKI(input("Introduce dato superior: "))
        dato_der = OKI(input("Introduce dato derecho: "))
        dato_inf = OKI(input("Introduce dato inferior: "))

        box = (dato_iz, dato_sup, dato_der, dato_inf)
    count = 1

    for frame in ImageSequence.Iterator(im):
        try:
            if corte == "s":
                n_imagen = im.crop(box)
            else:
                n_imagen = im
            nom_imagen = name + " " + str(count) + '.png'
            n_imagen.save(nom_imagen)
示例#12
0
import pyautogui
import time
from VALID import OKI, ns

#DELETING FILES FROM "Python" FOLDER.
while True:
    num = (OKI(input("Número de archivos: "))) + 1
    for i in range(0, num):
        pyautogui.moveTo(241, 132)
        time.sleep(0.3)
        pyautogui.click()
        time.sleep(0.5)
        pyautogui.click(button='right')
        time.sleep(0.6)
        pyautogui.moveTo(274, 699)
        time.sleep(0.3)
        pyautogui.click()
    conti = ns(input("¿Continuar?: "))
    if conti == "n":
        break
示例#13
0
            break
    return archivo


nuevo_directorio()

while True:
    #DEFINIMOS PARAMETROS
    FORMAT = pyaudio.paInt16
    CHANNELS = 2
    RATE = 44100
    CHUNK = 1024

    #INICIAMOS "pyaudio"
    audio = pyaudio.PyAudio()
    duracion = OKI(input("Indique duracion, en segundos, de la grabación: "))

    #INICIAMOS GRABACIÓN
    stream = audio.open(format=FORMAT,
                        channels=CHANNELS,
                        rate=RATE,
                        input=True,
                        frames_per_buffer=CHUNK)

    print("grabando...")
    frames = []

    for i in range(0, int(RATE / CHUNK * duracion)):
        data = stream.read(CHUNK)
        frames.append(data)
    print("grabación terminada")
示例#14
0
def año_valido(a):
    if a<1 or a>9999:
        a=año_valido(OKI(input("El año no puede ser menor de 1 ni mayor de 9999: ")))
    return a
示例#15
0
def mes_valido(n):  #VALIDAR DATO DE ENTRADA (MES)
    while n < 1 or n > 12:
        n = OKI(input("Introduzca un mes valido: "))
    return n
示例#16
0
def mes_valido(n):  #VALIDAR DATO DE ENTRADA (MES)
    while n < 1 or n > 12:
        n = OKI(input("Introduzca un mes valido: "))
    return n


while True:
    print(
        "\n------------------------------CALENDARIOS------------------------------\n"
    )
    print("""Escoja una opción:
A)Ver los calendarios correspondientes a un determinado año.
B)Ver el calendario correspondiente a un año y mes determinados.
""")
    opcion = AB(input("Introduzca su opción(A/B): "))
    if opcion == ("A"):
        anno = anno_valido(
            OKI(input("Introduce el año cuyos calendarios desea ver: ")))
        cl = calendar.TextCalendar()
        calendario = cl.formatyear(anno)
    else:
        anno = anno_valido(OKI(input("Introduzca el año: ")))
        mes = mes_valido(OKI(input("Introduzca mes: ")))
        cl = calendar.TextCalendar()
        calendario = cl.formatmonth(anno, mes)
    print("\n" + calendario)

    conti = ns(input("¿Desea continuar?(n/s): "))
    if conti == ("n"):
        break
示例#17
0
     change = ns(input("¿Cambiar tamaño?: "))
     try:
         clip = (VideoFileClip(vid).subclip(
             (float(start[0]), float(start[1])),
             (float(end[0]), float(end[1]))).resize(new_size(change)))
         clip.write_gif(name)
         print("\nTAMAÑO")
         siz = size(os.stat(name).st_size)
         print("\n")
         show(name)
     except:
         print("Hubo un problema al realizar la operación")
 else:
     name = input("Nombre del nuevo gif: ")
     file = (input("Palabra clave: ") + " ")
     speed = OKI(input("Velocidad: "))
     frames = []
     try:
         for i in os.listdir():
             if file in i:
                 frames.append(i[:-4])
         frames.sort(key=lambda x: int(x.split()[1]))
         #try:
         #frames_new = list(map(lambda x: x+".png",frames))
         #except:
         #print("busqueda se .jpg")
         frames_new = list(map(lambda x: x + ".png", frames))
         clip = ImageSequenceClip(frames_new, fps=speed)
         clip.write_gif(name)
         print("\nTAMAÑO")
         siz = size((os.stat(name)[6]))
示例#18
0
    lista=[D_hora,D_minuto,D_segundo]
    return lista

def entering_date(a,m,d,h,mi,s):
    D=datetime.datetime(a,m,d,h,m)
    return D


while True:
    print("INSTANT DATE")
    print("""El presente programa calcula las horas, minutos y segundos
entre dos fechas cualesquiera tanto del pasado como del futuro""")
    print("")
    time.sleep(1)
    print("*********PRIMER SUCESO*********",chr(7))
    año1=año_valido(OKI(input("Introduce año: ")))
    mes1=mes_valido(OKI(input("Introduce mes: ")))
    dia1=dia_valido(año1,mes1,OKI(input("Introduce día: ")))
    hora1=hora_valida()
    minuto1=mn_valido("m")
    segundo1=mn_valido("s")
    D1=entering_date(año1,mes1,dia1,hora1,minuto1,segundo1)#
    print("")
    print("*********SEGUNDO SUCESO*********",chr(7))
    año2=año_valido(OKI(input("Introduce año: ")))
    mes2=mes_valido(OKI(input("Introduce mes: ")))
    dia2=dia_valido(año2,mes2,OKI(input("Introduce día: ")))
    hora2=hora_valida()
    minuto2=mn_valido("m")
    segundo2=mn_valido("s")
    D2=entering_date(año2,mes2,dia2,hora2,minuto2,segundo2)#
        "DE LAS CORTES GENERALES":(66,96),"DEL GOBIERNO Y DE LA ADMINISTRACION":(97,107),
        "DE LAS RELACIONES ENTRE EL GOBIERNO Y LAS CORTES GENERALES":(108,116),
        "DEL PODER JUDICIAL":(117,127),"ECONOMIA Y HACIENDA":(128,136),
        "DE LA ORGANIZACION TERRITORIAL DEL ESTADO":(137,158),
        "DEL TRIBUNAL CONSTITUCIONAL":(159,165),"DE LA REFORMA CONSTITUCIONAL":(166,169)
        }

while True:
    usadas=[""]
    art_es=("")
    aciertos=0
    fallos=0
    print("TEST SOBRE LA ESTRUCTURA DE LA CONSTITUCIÓN ESPAÑOLA")
    print("""El usuario introducirá el nombre del título constitucional
en el que se encuentre el artículo indicado.""")
    num=OKI(input("Introduce el número de preguntas: "))
    print("")
    for i in range(num):
        while art_es in usadas: #PARA EVITAR REPETICIÓN DE ARTÍCULOS
            tit_selec=random.choice(titulos)
            art_es=random.randint((artics[tit_selec][0]),(artics[tit_selec][1]))
        print("Artículo",art_es)
        usadas.append(art_es)
        resp=input().upper()
        if resp==tit_selec:
            print("CORRECTO")
            aciertos+=1
        else:
            print("INCORRECTO")
            fallos+=1
        print("")
from VALID import ns, OKI
import subprocess

def factorial(n):
    if n == 0 or n == 1:
        resultado = 1
    elif n > 1:
        resultado = n * (factorial(n-1))
    return resultado

while True:
    num=OKI(input("Introduce número: "))
    factorial_de_n=factorial(num)
    print(factorial_de_n)

    conti=ns(input("¿Desea continuar?: "))
    if conti=="n":
        break
    subprocess.call(["cmd.exe","/C","cls"])
示例#21
0
        i = 0
    while not int(p) in range(0, 5):
        p = OKI(input("INTRODUZCA VALOR ENTRE 0 Y 4: "))
    total += p
    parti[i] += p
    i += 1
    #print(parti)


while True:

    print("¿SABE VALORARSE?")
    print("""Este test permite medir la atuoestima...""")
    print("\n1)AL REDACTAR EL CURRÍCULUM VITAE PARA UN IMPORTANTE TRABAJO:")
    time.sleep(1)
    validate(OKI(
        input("\nA)Estoy seguro de poder afrontar el nuevo empleo: ")))
    validate(OKI(input("\nB)Describo adecuadamente mis límites y defectos: ")))
    validate(
        OKI(
            input("""\nC)Pongo de manifiesto mis capacidades para relacionarme
con los demás en ambientes nuevos: """)))
    validate(
        OKI(input("\nD)Muestro iniciativa al personalizar el currículum: ")))
    validate(
        OKI(
            input(
                "\nE)Estoy dispuesto a aceptar los riesgos del nuevo trabajo: "
            )))
    validate(
        OKI(
            input(
示例#22
0
while True:
    print("TRABAJANDO CON TEXTOS")
    print("¿Que desea hacer?: ")
    print("A)CREAR UN ARCHIVO DE TEXTO")
    print("B)REPRODUCIR UN TEXTO")
    print("C)CONTAR EL NUMERO DE LINEAS DE TEXTO")
    print("D)CONTAR EL NUMERO DE PALABRAS DEL TEXTO")
    print("E)CONTAR EL NUMER0 DE CARACTERES DEL TEXTO")
    print("F)BUSCAR UNA PALABRA")
    print("G)ANALIZADOR DE TEXTO")
    op = opt(input("Introduzca aquí su opción: "),
             ["A", "B", "C", "D", "E", "F", "G"])
    if op == ("A"):
        nuevo_fichero = ((input("Fichero: ") + ".txt"))
        fichero = open(nuevo_fichero, "w")
        nl = OKI(input("Número de líneas: "))
        for i in range(0, nl):
            linea = input("Texto: ")
            fichero.write(linea + "\n")
        fichero.close()

    elif op == "G":
        car = []
        elem = []
        conta = 0
        contador = 0
        fichero = ver_text()
        print("")
        for linea in fichero:
            for i in linea:
                if i == (" ") or i == ('\n'):
    st = s0

    def generate_value():
        nonlocal st

        st *= exp((mu - 0.5 * sigma**2) * (1. / 365.) +
                  sigma * sqrt(1. / 365.) * gauss(mu=0, sigma=1))
        return st

    return generate_value


if __name__ == "__main__":
    seed(1234)
    #INPUTS
    initial = OKI(input("Initial price: "))
    target = OKI(input("Target: "))
    rang = OKI(input("Range: "))

    gbm = create_GBM(initial, 0.1, 0.05)  #100

    for _ in range(rang):  #1000
        st = gbm()
        print(st)
        if st >= target:  #130.
            print("Target reached, take profit.")
            break
    else:
        print("Did not reach target price.")

    print(st)
示例#24
0
def mes_valido(n):
    while n < 1 or n > 12:
        n = OKI(input("Introduzca un mes valido: "))
    return n
示例#25
0
def anno_valido(n):  #VALIDAR DATO DE ENTRADA (AÑO)
    while n < 1 or n > 9999:
        n = OKI(input("Introduzca un año valido: "))
    return n
示例#26
0
def año_valido(n):
    while n < 1 or n > 9999:
        n = OKI(input("Introduzca un año valido: "))
    return n
示例#27
0

#ESTE PROGRAMA CALCULA LA MEDIA, LA VARIANZA Y LA DESVIACIÓN TIPICA DE UNA LISTA DE DATOS.
while True:
    print("¿Que desea calcular?")
    print("A)MEDIA")
    print("B)VARIANZA")
    print("C)DESVIACIÓN TÍPICA")
    val = False
    while val == False:
        opciones = input(
            "Introduzca las opciones que desea calcular separadas por coma: ")
        lista_op = list(opciones)
        val = compru(lista_op)
    lista = []
    elem = OKI(input("Introduzca número de datos a calcular: "))
    for i in range(elem):
        dat = OK(input("Introduzca dato: "))
        lista.append(dat)
    print(lista)
    a = np.array(lista, float)
    if "A" in opciones:
        print("")
        res = a.mean()
        print("MEDIA: ", res)
    if "B" in opciones:
        res = a.var()
        print("")
        print("VARIANZA: ", res)
    if "C" in opciones:
        res = a.std()
示例#28
0
import subprocess
from VALID import OK, OKI, ns, ER

def AB(md):
    while md!=("A") and md!=("B"):
        md=input("Escriba solo \'A\' o \'B\' según su opción: ")
    return md

while True:
    n=OKI(input("Primer número: "))
    n2=OKI(input("Segundo número: "))
    o=[n,n2]
    o.sort()
    preg=ns(input("¿Desea ver la secuencia de sumas?: "))
    if preg==("s"):
        md=AB(input("Modo de presentacion en columna (\'A\')o en lista (\'B\'): "))
    summ=0
    li=[]
    for i in range(o[0],(o[1])+1):
        summ+=i
        if preg==("s") and md==("A"):
            print(summ)
        else:
            li.append(summ)
    if preg==("s") and md==("B"):
        print(li)
        print("")
    print("El sumatorio entre",o[0],"y",o[1],"es",summ,ER(summ),chr(7))

    c=ns(input("¿Continuar con otro sumatorio?: "))
    if c==("n"):
示例#29
0
from VALID import ns, OKI
import subprocess

while True:
    texto = input("Tu texto: ")

    abc = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuwxyz"

    k = OKI(input("Valor de desplazamiento: "))
    cifrad = ""

    for c in texto:
        if c in abc:
            cifrad += abc[(abc.index(c) + k) % (len(abc))]
        else:
            cifrad += c

    print("Texto cifrado: ", cifrad)
    conti = ns(input("¿Desea acontinuar?: "))
    if conti == ("n"):
        break
    subprocess.call(["cmd.exe", "/C", "cls"])
示例#30
0
def mes_valido(mes):#REVISAR
    while mes<1 or mes>12:
        mes=mes_valido(OKI(input("Mes no valido: ")))
    return mes