-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathError_Types.py
More file actions
86 lines (45 loc) · 1.52 KB
/
Copy pathError_Types.py
File metadata and controls
86 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
### Error Types ###
"""
Analizar el tipo de error que nos está lanzado el codigo, y evaluar la forma de solucionarlo.
- Que error a dado?
- Por qué lo ha dado?
- Como podemos solucionarlo?
"""
# SyntaxError
#print "Hola buenas a todos!" | el error se produce porque faltan los parentesis.
print("Hola buenas a todos!!")
# NameError
# print(language) | la variable 'language' no esta definida.
language = "Spanish"
print(language)
# IndexError
my_list = ["Python", "Swift", "Kotlin", "Dart", "JavaScript"]
print(my_list[0])
print(my_list[4])
print(my_list[-1])
#print(my_list[5]) | el indice de la lista está fuera del rango de la lista.
# MoluleNotFoundError
#import maths | el nombre del modulo es incorrecto, por tanto, no se encuentra el modulo deseado.
import math
# AttributeError
#print(math.PI) | error en la forma de acceder a un atributo.
print(math.pi)
# KeyError
my_dict = {"Nombre":"Joel", "Apellido":"Stadelman", "Edad":"23", 1:"Python"}
print(my_dict["Edad"])
#print(my_dict["Apelido"]) | se produce al llamar de forma erronea una key
print(my_dict["Apellido"])
# TypeError
#print(my_list["Nombre"]) | el error surge debido a que el indice de la lista debe ser un entero y se le esta pasando un string.
print(my_list[0])
# ImportError
#from math import PI
from math import pi
print(pi)
# ValueError
#my_int = int("10 Años") | son es posible transformar un str en int.
my_int = int("10")
print(my_int)
# ZeroDivisionError
print(4/2)
#print(4/0) | division entre cero