Fixing Difficult Errors |Section 2|Celestial Warrior

11 months ago
35

1

00:00:00,260 --> 00:00:06,089

Great, welcome again to this new video.

This is the third video about errors. We

3

00:00:06,089 --> 00:00:10,500

talked about syntax errors, we talked

about exceptions, and now we're going to

5

00:00:10,500 --> 00:00:15,179

talk about how to fix an error when you

don't understand the message, so let's

7

00:00:15,179 --> 00:00:23,189

focus on this error, a zero division error.

In case you were good in mathematics you

9

00:00:23,189 --> 00:00:26,789

could easily fix this error so you

you'll be able to understand that you

11

00:00:26,789 --> 00:00:32,820

cannot divide c by, you cannot divide

a number by 0 so you'd fix this by

13

00:00:32,820 --> 00:00:39,090

removing this expression here. However if

you were not that good in mathematics you

15

00:00:39,090 --> 00:00:43,590

may find this difficult to understand.

In that case the fastest way to fix this

17

00:00:43,590 --> 00:00:51,360

error is by copying this line here.

Control C, so select it copy it with ctrl

19

00:00:51,360 --> 00:01:02,510

C or right click and copy there and then

go to Google. Just paste it. Now on Google

21

00:01:02,510 --> 00:01:08,909

this got around a hundred thousand

results so Python is very popular and

23

00:01:08,909 --> 00:01:16,040

you'll get a solution for almost every

problem that you'll get with Python

25

00:01:16,040 --> 00:01:21,810

so before looking at documentation or

asking a question somewhere it's very

27

00:01:21,810 --> 00:01:26,070

likely that someone else has had your

issue before and i have asked a question

29

00:01:26,070 --> 00:01:29,640

about that and there is a solution about

that as well.

31

00:01:29,640 --> 00:01:37,280

And a very good question and answer

website is stackoverflow.com and

33

00:01:37,280 --> 00:01:41,640

almost always when you search for an

error on Google the first results will

35

00:01:41,640 --> 00:01:51,299

be from stackoverflow and so someone

has asked a question with this title. It says

37

00:01:51,299 --> 00:01:55,680

I faced an error when I run the program

using Python. So it's the same things as

39

00:01:55,680 --> 00:02:02,820

error as you like that. How to avoid that

error? And if it also talks about the

41

00:02:02,820 --> 00:02:06,110

desired output.

And there are two answers for this

43

00:02:09,899 --> 00:02:16,170

question. tThe answer with this green mark

here is the accepted answering and it

45

00:02:16,170 --> 00:02:22,800

has and it has the most up votes so 11

and this has 2 down votes some minus 2.

47

00:02:22,800 --> 00:02:27,209

Actually the difference between up votes

and down votes is in the favor of

49

00:02:27,209 --> 00:02:33,420

down votes and so these are two different

answers that you can look at. Usually you

51

00:02:33,420 --> 00:02:38,519

want to look at the accepted answer that

has the solution, however in this case

53

00:02:38,519 --> 00:02:45,209

this also has the explanation it says

you cannot divide by 0. This causes

55

00:02:45,209 --> 00:02:50,549

Python to raise an error. That's single

good answer and I think it didn't

57

00:02:50,549 --> 00:02:57,209

deserve to get to have this

balance of votes, but this one gives a

59

00:02:57,209 --> 00:03:02,910

solution on how to handle an error and

that takes us to another concept which

61

00:03:02,910 --> 00:03:08,489

is handling errors in Python. So let's

say you have a program you have a

63

00:03:08,489 --> 00:03:15,000

function that gets two input values and

then it divides those two input values.

65

00:03:15,000 --> 00:03:21,959

However sometimes the user may pass zero as

as a second input and in that

67

00:03:21,959 --> 00:03:25,170

case if you divide, let's say the first

value would be 2 and the second value

69

00:03:25,170 --> 00:03:34,019

would be 0, your program would crash and

if you want you can use exception

71

00:03:34,019 --> 00:03:38,639

handling to actually avoid that program

from crashing. And you can do that with a

73

00:03:38,639 --> 00:03:44,099

try and accept statements. Anyway we'll

cover that in the next lectures in this

75

00:03:44,099 --> 00:03:51,450

section. So this was about searching

for an error on Google and you can

77

00:03:51,450 --> 00:03:56,069

easily find the solution to that as you

see. These are very clear questions. It's

79

00:03:56,069 --> 00:04:01,319

a big community and everyone can vote up

and down and can comment and so

81

00:04:01,319 --> 00:04:07,380

basically the answers are very accurate.

However you'll not always find an answer on

83

00:04:07,380 --> 00:04:11,060

Google.

In that case it's time to ask your own

85

00:04:11,060 --> 00:04:17,389

question, so the first thing is again you

check if you understand the error and

87

00:04:17,389 --> 00:04:22,220

fix it if you understand it. The second

thing is you do a search on Google and

89

00:04:22,220 --> 00:04:27,229

if the first to fail to solve your

problem, then it's time to ask a question.

91

00:04:27,229 --> 00:04:34,820

And you can ask a question either inside

the course, so you can, while watching a

93

00:04:34,820 --> 00:04:40,669

video you can browse Q&A which stands

for question and answer and you can do a

95

00:04:40,669 --> 00:04:44,840

quick search if you find an existing

answer to your question here and if you

97

00:04:44,840 --> 00:04:48,349

cannot find it then you can ask a

question, or you can ask a question on

99

00:04:48,349 --> 00:04:55,669

stackoverflow. You can use this button

here, ask a question and I'll be happy to

101

00:04:55,669 --> 00:05:00,620

help you here on the course interface

Q&A section.

103

00:05:00,620 --> 00:05:06,020

Or other people can also help you own

stackoverflow, however something is very

105

00:05:06,020 --> 00:05:12,289

important to know. The structure of your

question is very important on getting a

107

00:05:12,289 --> 00:05:18,169

good answer. You know sometimes

there are very bad questions like let's

109

00:05:18,169 --> 00:05:23,750

say my code is not working how do I fix

this and that's all. With that very

111

00:05:23,750 --> 00:05:28,759

little information is very hard to get a

good answer so it's very important to

113

00:05:28,759 --> 00:05:33,919

ask a good question and I'll show you

how to ask a good programming question

115

00:05:33,919 --> 00:05:38,000

in the next lecture. So that's a very

important lecture as well. See you there!

Loading comments...