Haciendo el ejecricio figuras y ordenando los

ejercicios.
El nombre del Ejrecicio de figuras es paralelEjer1
en carpeta Python en subcarpeta pt2
master
victor 11 months ago
parent bf4264999b
commit 3f21c911b6

@ -0,0 +1,17 @@
from multiprocessing import Process
import os
def hijo():
print("Padre: %d, Hijo: %d\n" % ( os.getppid(),os.getpid()))
os._exit(0)
def padre():
while True:
p = Process(target=hijo)
p.start()
print ("\nNuevo hijo creado " , p.pid)
p.join()
reply = input("Pulsa 's' si quieres crear un nuevo proceso\n")
if reply != 's':
break
if __name__ == '__main__':
padre()

@ -0,0 +1,12 @@
import subprocess
def iniciaPrograma():
try:
SW_SHOWMAXIMIZED = 3
info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = SW_SHOWMAXIMIZED
subprocess.Popen('Notepad.exe', startupinfo=info)
except subprocess.CalledProcessError as e:
print(e.output)
iniciaPrograma()
input("Pulsa una tecla para terminar la ejecución")

@ -0,0 +1,16 @@
import subprocess
import time
def CrearProceso():
try:
"""SW_SHOWMAXIMIZED = 3
info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = SW_SHOWMAXIMIZED"""
proc = subprocess.Popen('notepad.exe')
return proc
except subprocess.CalledProcessError as e:
print(e.output)
p = CrearProceso()
print ("El PID de este proceso es: " + str(p.pid))
time.sleep(5)

@ -0,0 +1,12 @@
import threading
def actividad():
print ("Escribo desde un hilo")
return
print ("INICIO")
hilos = list()
for i in range(50):
t = threading.Thread(target=actividad)
hilos.append(t)
t.start()
print ("ESCRIBO EN PRINCIPAL")

@ -0,0 +1,9 @@
import threading;
def Saludo():
print('hola')
t=threading.Thread(target=Saludo)
t.start()
print('hola')

@ -0,0 +1,10 @@
import threading
def escribeY():
for i in range(100):
print ("y", end="")
return
print ("INICIO")
t = threading.Thread(target=escribeY)
t.start()
for i in range(100):
print ("X", end="")

@ -0,0 +1,16 @@
import threading
import time
import random
def tareaUno():
global Realizado
#time.sleep (random.random())
if not Realizado:
print("Tarea realizada")
Realizado = True
return
Realizado = False
t = threading.Thread(target=tareaUno)
t.start()
tareaUno()
time.sleep(1)

@ -0,0 +1,20 @@
import threading
import time
import random
def tareaUno():
global Done
time.sleep (random.random())
if not Done:
print("Tarea realizada")
Done = True
else :
print ("tarea NO REALIZADA")
return
Done = False
hilos = list()
for i in range(50):
t = threading.Thread(target=tareaUno)
hilos.append(t)
t.start()
tareaUno()
time.sleep(1)

@ -0,0 +1,13 @@
import logging
import threading
import time
def thread_Apellido(name):
print (name + " Rodríguez")
#print (name + " Rodríguez\n")
nombres = ["Julio", "Javier", "Eladio", "Jose", "Manuel"]
hilos = list()
for n in nombres:
t = threading.Thread(target=thread_Apellido, args=(n,))
hilos.append(t)
t.start()

@ -0,0 +1,24 @@
import threading
def TriangleArea(base,hight):
print((base * hight)/2)
def RectangleArea(width,hight):
print(width*hight)
def RectangleDosArea(width,hight):
print(width*hight)
def TriangleDosArea(base,hight):
print((base * hight)/2)
tr = threading.Thread(TriangleArea(10,12))
tr2 = threading.Thread(TriangleDosArea(2,5))
rect = threading.Thread(RectangleArea(8,12))
rect2 = threading.Thread(RectangleDosArea(6,5))
tr.start
tr2.start
rect.start
rect2.start
Loading…
Cancel
Save

Powered by INFORMATICA.FP.EDU.ES.