- 1

Why errors occur in python and what type of errors occur due to what types of mistakes

Pls answer my question

14th Sep 2020, 2:57 AM
Bhuvan Blaster
Bhuvan Blaster - avatar
13 Respostas
+ 2
A programming language is just an interface to the machine language that the computer understands. So all your code u write is interpreted / compiled depending on language used and turn into machine language 0s and 1s. So if write anything that the computer doesn't understand this causes the error. Take a look at memory of a computer, these are just blocks of 0s and 1s. If u create a list memory is reserved for the list and probably u would get an index error if u try the index the list with a number out of range. In short, we have syntactical errors (mistyping), exceptions (generated due to uncaught errors)
14th Sep 2020, 8:41 PM
Kirabo Ibrahim
Kirabo Ibrahim - avatar
+ 1
In your code ( never mind youve got them ) is not in quotes thus is not considered as a string and hence generating syntax error.
14th Sep 2020, 3:15 AM
Arsenic
Arsenic - avatar
+ 1
Ok thank you
14th Sep 2020, 3:17 AM
Bhuvan Blaster
Bhuvan Blaster - avatar
+ 1
There are mainly two types of errors in Python: 1. Syntax errors 2. Exceptions or runtime errors 1. Syntax errors Whenever you break a grammar rule while writing your Python code. For example Example 1: int x = 5 Example 2: print("hello) Example 3: if True: break Obviously there can be infinitely more examples. In example 1, error occurs because Python is a dynamically typed language so you can't specify data type. In example 2, there's an error because you didn't enclose the string within double quotes. In example 3, error occurs because you can't use a break statement if not within a loop. 2. Exceptions These are errors that are not because of a grammatical mistake. They can be of many different types like: ZeroDivisionError KeyError ModuleNotFoundError NameError ValueError Are some common exceptions. Now, as there are too many kinds of exceptions, (ps you can also make your custom exceptions) I can't explain them all. But hopefully I was able to clarify some of your doubts. Good luck ;)
15th Sep 2020, 7:46 PM
Animesh Singh
Animesh Singh - avatar
0
A syntax error occur when you don't type anything according to it's syntax (or the way it should be typed).
14th Sep 2020, 3:07 AM
Arsenic
Arsenic - avatar
0
x = input (" ") if x = never mind youve got them : print ("evernay indmay ouyay otgay hemtay")
14th Sep 2020, 3:14 AM
Bhuvan Blaster
Bhuvan Blaster - avatar
0
Thanks for your kind information
14th Sep 2020, 3:17 AM
Bhuvan Blaster
Bhuvan Blaster - avatar
0
Please share your code here to help us to know your problem to help you .
14th Sep 2020, 7:25 AM
Fareed
Fareed - avatar
0
If the code is syntactically wrong then the interpreter will throw a SyntexError. If you try to divide a number with 0 then it'll throw a ZeroDivisionError.
15th Sep 2020, 3:01 AM
Rohit Dhas
Rohit Dhas - avatar
0
Thanq
18th Sep 2020, 3:42 AM
Bhuvan Blaster
Bhuvan Blaster - avatar
- 1
Why does syntax error occor
14th Sep 2020, 3:01 AM
Bhuvan Blaster
Bhuvan Blaster - avatar
- 1
And how should I correct it
14th Sep 2020, 3:02 AM
Bhuvan Blaster
Bhuvan Blaster - avatar
- 1
Ok should I send my code
14th Sep 2020, 3:12 AM
Bhuvan Blaster
Bhuvan Blaster - avatar