Skip to content
Snippets Groups Projects
Commit 1ba0e9c1 authored by Carla Elena Gomez Alvarado's avatar Carla Elena Gomez Alvarado
Browse files

Ejercicio 2 importado desde el Jupyter Hub

parent 0147b0c2
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
#Solicitar al usuario ingreso de un número entero, siendo row una variable global
input_row= input('Ingrese un numero entero: ')
# Try intenta hacer algo, si el numero ingresado no es un entero va al except
try:
row=int(input_row)
except:
print("El número ingresado no es entero")
```
%% Output
Ingrese un numero entero: 3
%% Cell type:code id: tags:
``` python
# Función Pascal_triangle
def Pascal_triangle(row):
for line in range(1, row + 1):
C = 1;
for i in range(1, line + 1):
# El primer elemento de cada fila del triangulo de pascal es 1
print(C, end = " ");
#Aplicación del binomio de Newton
C = int(C * (line - i) / i);
print("");
```
%% Cell type:code id: tags:
``` python
if type(row) == int:
Pascal_triangle(row)
else:
print("el número ingresado no es entero")
```
%% Output
1
1 1
1 2 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment