Está en la página 1de 6

ESCUELA MILITAR DE INGENIERIA

“MCAL. ANTONIO JOSE DE SUCRE”


BOLIVIA

PRACTICA DE FUNCIONES
CARRERA : Ciencias Básicas
SEMESTRE : 2do Semestre” G”
MATERIA : Programación
DOCENTE : Lic. Danitza Solar
ESTUDIANTE : Karol Emilia Argandoña Choque
Dery Ustariz Acosta
CODIGO : C 8954 - 0
C 8763 - 7
FECHA : Diciembre 04 del 2019

COCHABAMBA – BOLIVIA
2 EJERCICIO

CODIGO
def sumadenumeros():
n= int(input("Ingrese el primer numero:"))
m= int(input("Ingrese el segundo numero:"))
suma= m + n
return suma
resultado = sumadenumeros()
print("La suma es:")
print(resultado)

CAPTURA
3 EJERCICIO

CODIGO

def calculo():
n= int(input("Ingrese el primer numero:"))
m= int(input("Ingrese el segundo numero:"))
if m== n or n== m:
print("los numeros son iguales")
else:
print("los numeros no son iguales")
return
r= calculo()

CAPTURA
10

CODIGO

import random

def numerosprimos():
primos = []
for i in range(1, 31):
if esprimo(i):
primos.append(i)

print("Los primos del 1 al 30 son:")


print(primos)

def esprimo(numero):
contador = 0
for i in range(1, numero + 1):
if numero % i == 0:
contador = contador + 1
if contador == 2:
return True
return False

numerosprimos()

CAPTURA
12

CODIGO

def rectangulo():
filas = ''
n=int(input("Anchura del rectangulo: "))
m=int(input("altura del rectangulo: "))
v=str(input("Caracter a utilizar: "))
for i in range(n):
filas = filas + v + ' '
for i in range(m):
print(filas)

rectangulo()

CAPTURA
16

CODIGO
def llenar(tf, tc):
mat = []
for i in range(tf):
mat.append([])
for j in range(tc):
v = int(input("Introduce un valor: "))
mat[i].append(v)
return mat
def mostrar(mat, tf, tc):
for i in range(tf):
print(mat[i])
def sumaElem(mat, tf, tc):
sum = 0
for i in range(tf):
for j in range(tc):
sum = sum + mat[i][j]
return sum

tf = int(input("Introduce tamaño filas: "))


tc = int(input("Introduce tamaño columnas: "))
m1 = llenar(tf, tc)
s1 = sumaElem(m1, tf, tc)

tf = int(input("Introduce tamaño filas: "))


tc = int(input("Introduce tamaño columnas: "))
m2 = llenar(tf, tc)
s2 = sumaElem(m2, tf, tc)

if s1 > s2:
print("La matriz con mayor suma es la primera")
elif s2 > s1:
print("La matriz con mayor suma es la segunda")
else:
print("Son iguales")
CAPTURA

También podría gustarte