Professional Documents
Culture Documents
W. Arturo Osorio C.
GEOINFORMÁTICA
Profesor: Germán A. Prieto
24 de agosto de 2017
1
1 #!/ usr/bin/env python
2 # -*- coding : cp1252 -*-
3 # -*- coding : utf -8 -*-
4 # -*- coding : IBM850 -*-
5 # Programa que imprime una tabla con los valores de x, sinh(x) y cosh(x)
...
6
7 import math
8 import numpy as np
9 import t e x t t a b l e as t t
10
11 tab = t t . T e x t t a b l e ( )
12
13 x = [ [ ] ] #En el espacio vacı́o va el encabezado ...
14
15 fo r i in np . a r a n g e ( 0 , 6 . 5 , 0 . 5 ) :
16 x . append ( [ i , math . s i n h ( i ) , math . c o s h ( i ) ] )
17
18 tab . add rows ( x )
19 tab . s e t c o l s a l i g n ( [ ’ r ’ , ’ r ’ , ’ r ’ ] )
20 tab . h e a d e r ( [ ’ x ’ , ’ Sinh ( x ) ’ , ’ Cosh ( x ) ’ ] ) # Éste es el
encabezado ...
21 print ( tab . draw ( ) )
2
3. Programa que imprime dos numeros enteros y el resultado
de sus operaciones matemáticas básicas:
Se programó un código que le pregunta al usuario dos números enteros y con ellos
realiza las cuatro operaciones mencionadas en el taller; suma, resta, multiplicación y
división de la siguiente manera:
1 #!/ usr/bin/env python
2 # -*- coding : cp1252 -*-
3 # -*- coding : utf -8 -*-
4 # -*- coding : IBM850 -*-
5 #Código para mostrar dos nú meros enteros y los resultados de sus
operaciones .
6
7 i n t x t = i n p u t ( ” I n g r e s e dos números e n t e r o s s e p a r a d o s por un e s p a c i o : ” )
8
9 a ,b = intxt . s p l i t ()
10 a = int (a)
11 b = int (b)
12
13 print ( ’ Los números son : ’ , a , ’ y ’ , b )
14 print ( ’ La suma e s : ’ , a+b )
15 print ( ’ La r e s t a de a−b e s : ’ , a−b )
16 print ( ’ El p r o d u c t o e s : ’ , a ∗b )
17 print ( ’ La d i v i s i ón de a /b e s : %5.4 f ’
18 % ( a /b ) )