0% found this document useful (0 votes)
16 views23 pages

AI Python For Beginners Part2-en-US

This document introduces the coding environment used in the AI Python for Beginners course, specifically a Jupyter notebook. It highlights key features such as the navigation pane, video controls, and the importance of the 'Shift + Enter' command for running code. The document encourages hands-on practice with coding and using a chatbot for assistance in learning programming concepts.

Uploaded by

ouyang4work
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views23 pages

AI Python For Beginners Part2-en-US

This document introduces the coding environment used in the AI Python for Beginners course, specifically a Jupyter notebook. It highlights key features such as the navigation pane, video controls, and the importance of the 'Shift + Enter' command for running code. The document encourages hands-on practice with coding and using a chatbot for assistance in learning programming concepts.

Uploaded by

ouyang4work
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

AI Python for Beginners Part2

0:03
Now that you've seen how you can use the chatbot to write code for you, let's take a look
at the coding environment we'll be using in this course to actually run code.

0:13
In the next lesson, you'll see an environment that looks a bit like this.

0:16
I want to highlight the main sections.

0:19
The left portion is the Navigation Pane, which can shut or reopen like this.

0:25
This middle area is where you'd be able to write and run code, and over to the right is the
video player.

0:33
I'm going to very quickly run through a few features of this learning platform, which is
the play button.

0:38
So please feel free to pause the video anytime you want to take a break or think over
something or go experiment with the code.

0:46
You can also control the speed of the video under settings.

0:50
So if you think I'm talking too slowly, speed me up.

0:54
You can move this video to picture in picture.

0:57
This middle tab also lets you control the size of the coding region versus a video player.

1:03
Then get rid of the picture in picture.

1:05
Oh, and this little arrow is another way to trigger picture in picture.

1:09
So it pops up picture in picture.

1:10
And then to bring back the video, that little arrow there.
1:13
Let me close the left Navigation Pane and let's focus on this coding environment here in
the middle.

1:20
This coding environment is called a Jupiter notebook is the exact same coding
environment that many professional programmers and data scientists use day-to-day.

1:31
But don't worry, we'll learn one step at a time how to use these tools.

1:34
You may remember that in the last lesson, we used to chat bot.

1:38
So click this chat button to pop this up.

1:44
All right, so, so I'd like to see the code, yes.

1:48
And so here's the code.

1:50
And now I'm going to click this button to copy the code, and then let's close the chat bot.

1:56
And if I want to run the code, I'm going to go to this coding environment, click my cursor
here, and then I'm going to hit command V or control V depending on your operating
system to paste the code that I just copy out of the chat bot.

2:10
And now I'd like to go through what's probably the single most important command in a
Juveda notebook, which is shift enter.

2:16
So press and hold Shift and while holding down shift, and then I'm going to hit enter and
it runs this line of code.

2:21
And so it says hello world.

2:24
In the next lesson, we'll actually get a lot more practice on how to run code like you just
saw me do.

2:30
And I will invite you to try copy pasting some code and then running shift enter yourself.

2:37
There's one thing to note here.
2:38
This platform will save your work only for two hours.

2:42
So if you stop a lesson before the end and come back to finish it more than two hours
later, the notebook will have reset and you have to start at the top and run all the cells
again.

2:51
But that's fine too.

2:52
This short course consists of a number of different videos or a number of different
lessons, which are indicated here in this left navigation bar.

3:01
I recommend you take these lessons one at a time and in order.

3:05
When you finish watching each video all the way to the end, you get a green check mark
next to each of these lessons in turn.

3:12
And when you turn all of these into check marks or when this progress turns into 100%,
that's when you're finished the lesson.

3:21
I would also love to get any feedback you have on this course, which you can share with
us by clicking on the course feedback link down here in the lower left.

3:29
So that's it for this learning platform.

3:32
I hope you remember the most important command I say just now, which is shift enter.

3:38
Let's go on to the next lesson where you start to run your own computer program.

4:01
In this lesson, I hope you try running your own Python code rather than just listening to
me talk and watching me run the code later in this video, I'd like to invite you to pause
this video and actually go into the juvenile notebook region of this learning environment
and run your own code.

4:18
I think learning to code has some similarities to learning a new human language.

4:24
You can listen to the teacher tell you about how to speak French or Spanish or some of
the language, but unless you open your mouth and practice speaking that language
yourself, how much you can actually learn, you know, will be limited.
4:37
And learning to use a programming language is like that too.

4:40
It really helps.

4:41
And you don't just watch me do it.

4:43
But if you actually pause the video and at the right time, which will come a little bit, try
running the code yourself in the Jupiter Notebook region.

4:53
Hopefully you see this.

4:55
And the first thing I want you to do is use the mouse to click on this print.

4:59
Hello World and then run that command.

5:02
Someone do that right now Shift enter and now the computer prints Hello world.

5:06
Why don't you pause the video and go do that yourself?

5:10
Just hit shift enter or shift return and your computer will print Hello world.

5:15
If you just ran Hello World, then congratulations, you just joined the millions of others
that started their computer programming adventure by running this line of code.

5:24
Now let's go on to see how we can use a chat bot to write slightly more complex
programs.

5:34
I'm going to demonstrate a sequence of operations 1st and then after that, I'd like you to
pause a video and go through the same thing yourself.

5:41
I'm going to open the chat bot and then type in this prompt, modify the code below to
have it say hello to me.

5:46
Here's the code.
5:47
My name is Andrew.

5:48
And so here we like to write code to say hello not to the world, but to you.

5:53
Let me show you how I'm going to do that.

5:56
So pop up the chat bot by clicking the chat button at the bottom, and then we're going to
say modify the code below to have it say hello to me.

6:11
We call this print Hello world and then my name is Andrew.

6:20
And when you do this, please substitute your own name for mine.

6:24
And now it says you can modify the code like this.

6:27
Print Hello Andrew.

6:29
And now I'm going to click this button to copy the code.

6:33
And I'm then going to paste the code and hit shift enter.

6:38
And now it will say Hello, Andrew, in case you want to copy paste a text from here into
the chat bot, that's fine too.

6:47
You can highlight this text and then hit, you know, command C or control Z and copy
paste this into the chat bot.

6:55
So what I'd like you to do now is go ahead and pause the video.

6:58
And why don't you get the chat bot to modify this code to have it say hello to you and
then paste the code into the cell and have your computer say hello to you.

7:10
So hopefully you had fun doing that.

7:12
For the next law exercise, let's have the computer say hello to someone you love.
7:19
So to do this, I'm going to copy paste here.

7:23
Let me type in the names of my kids, Happy and you.

7:28
My daughter is actually called Nova, but she likes to go by Happy, so that's hello to my
kids.

7:33
Why don't you do that as well?

7:34
Get the computer, say hello, not just the world, not just to you, but to someone that you
love.

7:39
Now you may be wondering what this text is.

7:44
There's a# or hash sign followed by a bunch of texts here.

7:49
This is what's called a comment in the code.

7:53
So this Jupiter notebook cell says # sign or hash sign.

7:57
There's a comment Python with all the signs.

7:59
So if I click on to the cell and feel free to follow along in your own Jupiter notebook and
hit shift enter, what do you think will happen?

8:06
Right.

8:06
Shift enter, nothing at all happens.

8:09
It generates no output.

8:10
The computer does nothing at all because as developers, we find that sometimes it's
useful to write some text to remind ourselves or to let someone else reading our code
know what the code is about.

8:21
And so comment is a type of text that we include in our programs that the computer
knows to ignore.

8:27
In contrast, this is a print command or we also say is a print statement.

8:32
So if I run this, then it says it prints out.

8:36
This is a print statement.

8:38
Now let's look at a more complex due to the notebook coding cell.

8:42
That's what one of these things is called and see what it does.

8:44
So the first 3 lines are comments.

8:47
So it will ignore this when you run to cell.

8:51
Here's a print command or print statement says print.

8:53
Hello Andrew.

8:55
And then here I'm going to say a follow up with National printing command.

8:58
How's your day going?

8:59
So what do you think will happen when I run to cell?

9:01
There are 6 lines in this cell but only two of them are commands and the other four are
comments.

9:10
So when I run this it will print Hello Andrew, how's your day going?

9:15
And all the comments are ignored.

9:17
So again, anytime, please pause the video, go ahead and click into the children notebook
cell and hit shift enter so you can see this for yourself.
9:25
And if you feel so inspired, feel free to modify this, You know, go ahead and add another
line of comment, blah, blah, blah, and run that.

9:35
And it should ignore these extra lines of comments as well.

9:40
Now it turns out that when we're programming, all of us make mistakes all the time.

9:45
I make typos.

9:46
I make mistakes when I code.

9:48
There's a very normal part of programming, so here's a piece of code with an error in it.

9:55
We call errors in coding bugs, but when you run codes with an error or a bug in it, then
sometimes you get an error message like this.

10:03
Sometimes I get an error message go boy, I have no idea what this means.

10:08
Fortunately, you can ask a chat bot how to fix the code.

10:14
So let's take this baggy line of codes and let's ask the chat bot to fix it for us.

10:19
Here's a chat bot.

10:20
I'm going to clear the conversation and then I'm going to ask it what is wrong with this
code and how do I fix it?

10:27
And then it gives an explanation issue.

10:29
The code is quotation mask around string and all matching.

10:32
Here's the corrected code print.

10:35
Hello Andrew.
10:37
So I can actually go back to my notebook and edit the code.

10:42
I just paste in the right answer.

10:43
We can edit it however you want and then run it and this fixes it.

10:48
So finding and fixing errors, also known as finding, fixing bugs in computer programming
has really changed with chat bots because for many at least simple mistakes such as
little typos, which we had here, chat bots are very good at spotting what went wrong.

11:06
And if you're interested, you can also use a chat bot to explain error messages to you.

11:13
So for example, if I was asked what does this error message mean?

11:19
And then paste it, you know the error message that we saw, then it actually gives a
pretty decent explanation for what's going on.

11:29
And right now you may not know what some of these terms mean, like what is a string or
what is scanning the string.

11:37
By the end of this short course, you will have learned a lot of the vocabulary like what is
a string in Python to help you understand messages like these.

11:46
So that almost takes us to the end of the lesson.

11:50
After you're done watching this video before going on to the next lesson, I hope you go
through some of these little practice exercises.

11:56
So I'll, I'll do the first one.

11:57
So let's see print blue.

12:00
That is my favorite colour.

12:02
It's also my son's favorite colour, not my daughter's.
12:05
And I hope you practice writing and running print statements to have it say how you
feeling today.

12:12
Go ahead, make a generic error.

12:13
You know, we all write code with errors or bugs.

12:16
It's good for you to sometimes do that too, even deliberately, and then see if you get the
chat bot to fix the error.

12:22
So I hope you have fun with these practice exercises.

12:26
And when you're done, let's go on to the next lesson where we'll start to talk about data,
which is a key ingredient of both AI as well as of Python programs.

12:37
I'll see you in the next video.

12:47
Now that you've run your first program, I need to share with you some tips for learning to
code.

12:54
1st is do try the code, do pause the videos and do run the code.

13:00
And to test your understanding of how a line of code works, try asking yourself questions
like, what do I think will happen if I leave a quotation mark out, or if I accidentally have
two instead of one closing parentheses?

13:15
And then change the code, run it and see if you're right to give yourself practice.

13:21
I also encourage you to complete the practice exercises, and I also encourage you to use
the chat bot as often as you want.

13:30
Think of the AI chat bot as your buddy or your coding companion who knows Python
pretty well and is patient and just wants to help you out.

13:38
While going through this course, you might think of some what if or why questions.

13:43
What if I did that?
13:44
Why is it like that?

13:45
Go ahead and ask the chat bot as many questions as you want.

13:49
You can also ask your chat bot to explain code and sometimes asking it, how did this
code work?

13:55
What is this doing?

13:56
That might help you understand what a piece of code is actually doing.

14:01
And this is actually what professional software developers do today as well.

14:05
When there's a piece of code I don't understand, I will paste it into chat box sometimes
and see if it can help me out.

14:12
And when you're coding and running code, it's totally fine if something doesn't work the
first time around.
**AI Python 初学者第二部分**

0:03\
现在你已经看到了如何使用聊天机器人帮你编写代码,接下来让我们看看在本课程中我们将使用的编程环境,以便实际运行代码。

0:13\
在下一课中,你会看到一个类似这样的环境。

0:16\
我想强调一下主要部分。

0:19\
左侧是导航面板,可以关闭或重新打开。

0:25\
中间区域是你编写和运行代码的地方,右侧是视频播放器。

0:33\
我将快速介绍这个学习平台的几个功能,首先是播放按钮。
0:38\
所以请随时暂停视频,以便休息、思考或尝试代码。

0:46\
你还可以在设置中控制视频的播放速度。

0:50\
如果你觉得我讲得太慢,可以加快速度。

0:54\
你可以将视频切换到画中画模式。

0:57\
中间的标签还可以让你控制代码区域和视频播放器的大小。

1:03\
然后关闭画中画。

1:05\
哦,这个小箭头是另一种触发画中画的方式。

1:09\
它会弹出画中画。

1:10\
然后要恢复视频,点击那个小箭头。

1:13\
让我关闭左侧的导航面板,让我们专注于中间的编程环境。

1:20\
这个编程环境叫做 Jupyter Notebook,是许多专业程序员和数据科学家日常使用的编程环境。

1:31\
但别担心,我们会一步一步地学习如何使用这些工具。

1:34\
你可能还记得在上节课中,我们使用了聊天机器人。

1:38\
所以点击这个聊天按钮来弹出它。
1:44\
好的,所以我想看看代码,是的。

1:48\
这是代码。

1:50\
现在我要点击这个按钮来复制代码,然后关闭聊天机器人。

1:56\
如果我想运行代码,我会进入这个编程环境,点击光标,然后按 Command V 或 Control V(取决于你的操作系统)来粘贴我刚从聊天机器人复制的代码。

2:10\
现在我要介绍 Jupyter Notebook 中最重要的命令,那就是 Shift + Enter。

2:16\
按住 Shift 键,然后按 Enter,它会运行这行代码。

2:21\
所以它输出了 Hello World。

2:24\
在下一课中,我们实际上会进行更多练习,学习如何运行代码,就像你刚才看到我做的那样。

2:30\
我会邀请你尝试复制粘贴一些代码,然后自己运行 Shift + Enter。

2:37\
这里有一点需要注意。

2:38\
这个平台只会保存你的工作两小时。

2:42\
所以如果你在课程结束前停止,并在两小时后回来完成,Notebook 会重置,你必须从头开始并重新运行所有单元格。

2:51\
但这也没关系。

2:52\
这个短期课程由多个不同的视频或课程组成,这些课程在左侧导航栏中显示。

3:01\
我建议你按顺序一次学习一个课程。

3:05\
当你完整观看每个视频后,你会在这个课程旁边看到一个绿色的勾号。

3:12\
当你把所有课程都打上勾号,或者进度达到 100% 时,你就完成了课程。

3:21\
我也非常希望得到你对这个课程的反馈,你可以点击左下角的课程反馈链接与我们分享。

3:29\
这就是这个学习平台的介绍。

3:32\
我希望你记住我刚才说的最重要的命令,那就是 Shift + Enter。

3:38\
让我们进入下一课,开始运行你自己的计算机程序。

4:01\
在这节课中,我希望你尝试运行你自己的 Python 代码,而不仅仅是听我讲或看我运行代码。在这节课的后面,我会邀请你暂停视频,进入这个学习环境的 Jupyter
Notebook 区域,运行你自己的代码。

4:18\
我认为学习编程与学习一门新的人类语言有一些相似之处。

4:24\
你可以听老师教你如何说法语或西班牙语,但除非你开口练习说这种语言,否则你能真正学到的东西是有限的。

4:37\
学习使用编程语言也是如此。

4:40\
它确实有帮助。

4:41\
你不只是看我做。
4:43\
但如果你真的暂停视频,在适当的时候(稍后会提到),尝试在 Jupyter Notebook 区域运行代码。

4:53\
希望你能看到这个。

4:55\
我想让你做的第一件事是用鼠标点击这个 print。

4:59\
Hello World,然后运行这个命令。

5:02\
有人现在就这样做 Shift + Enter,现在计算机打印了 Hello World。

5:06\
为什么不暂停视频,自己去试试呢?

5:10\
只需按 Shift + Enter 或 Shift + Return,你的计算机就会打印 Hello World。

5:15\
如果你刚刚运行了 Hello World,那么恭喜你,你刚刚加入了数百万通过运行这行代码开始计算机编程冒险的人。

5:24\
现在让我们继续看看如何使用聊天机器人编写稍微复杂一些的程序。

5:34\
我将演示一系列操作,然后我希望你暂停视频,自己完成同样的操作。

5:41\
我将打开聊天机器人,然后输入这个提示:修改下面的代码,让它对我说你好。

5:46\
这是代码。

5:47\
我的名字是 Andrew。

5:48\
所以我们希望编写代码,让它对你说你好,而不是对世界说你好。

5:53\
让我向你展示我将如何做到这一点。

5:56\
所以点击底部的聊天按钮弹出聊天机器人,然后我们会说:修改下面的代码,让它对我说你好。

6:11\
我们称之为 print Hello World,然后我的名字是 Andrew。

6:20\
当你这样做时,请用你自己的名字替换我的名字。

6:24\
现在它说你可以像这样修改代码。

6:27\
Print Hello Andrew。

6:29\
现在我要点击这个按钮来复制代码。

6:33\
然后我将粘贴代码并按 Shift + Enter。

6:38\
现在它会说 Hello, Andrew,如果你想从这里复制粘贴文本到聊天机器人,那也是可以的。

6:47\
你可以高亮显示这个文本,然后按 Command C 或 Control Z,复制粘贴到聊天机器人中。

6:55\
所以我现在希望你做的是暂停视频。

6:58\
为什么不试试让聊天机器人修改这个代码,让它对你说你好,然后将代码粘贴到单元格中,让你的计算机对你说你好。

7:10\
希望你在这个过程中感到有趣。
7:12\
下一个练习,让计算机对你爱的人说你好。

7:19\
为此,我将在这里复制粘贴。

7:23\
让我输入我孩子的名字,Happy 和 you。

7:28\
我女儿其实叫 Nova,但她喜欢别人叫她 Happy,所以这是对我孩子的问候。

7:33\
为什么不试试呢?

7:34\
让计算机说你好,不仅仅是对世界,也不仅仅是对你,而是对你爱的人。

7:39\
现在你可能想知道这段文字是什么。

7:44\
有一个#号或井号,后面跟着一些文字。

7:49\
这被称为代码中的注释。

7:53\
所以这个 Jupyter Notebook 单元格说#号或井号。

7:57\
这是一个注释,Python 会忽略所有带#号的文字。

7:59\
如果我点击单元格,你可以跟着在你自己的 Jupyter Notebook 中操作,然后按 Shift + Enter,你认为会发生什么?

8:06\
对。

8:06\
Shift + Enter,什么也没有发生。
8:09\
它没有生成任何输出。

8:10\
计算机什么也没做,因为作为开发者,我们有时会发现写一些文字来提醒自己或让其他人知道代码的用途是很有用的。

8:21\
所以注释是我们包含在程序中的一种文本,计算机会忽略它。

8:27\
相比之下,这是一个打印命令,或者我们也称之为打印语句。

8:32\
如果我运行这个,它会输出。

8:36\
这是一个打印语句。

8:38\
现在让我们看一个更复杂的 Jupyter Notebook 单元格。

8:42\
这就是这些单元格的名称,看看它会做什么。

8:44\
所以前三行是注释。

8:47\
所以当你运行单元格时,它会忽略这些。

8:51\
这里有一个打印命令或打印语句,说 print。

8:53\
Hello Andrew。

8:55\
然后这里我会说一个后续的打印命令。

8:58\
你今天过得怎么样?

8:59\
所以你认为当我运行这个单元格时会发生什么?

9:01\
这个单元格有六行,但只有两行是命令,其他四行是注释。

9:10\
所以当我运行这个时,它会打印 Hello Andrew,你今天过得怎么样?

9:15\
所有的注释都被忽略了。

9:17\
所以再次提醒,请随时暂停视频,进入 Jupyter Notebook 单元格,按 Shift + Enter,这样你可以自己看到这个。

9:25\
如果你有灵感,可以随意修改这个,比如添加另一行注释,然后运行它。

9:35\
它应该也会忽略这些额外的注释行。

9:40\
现在事实证明,当我们编程时,所有人都会经常犯错误。

9:45\
我会打错字。

9:46\
我在编码时会犯错误。

9:48\
这是编程中非常正常的一部分,所以这里有一段有错误的代码。

9:55\
我们把代码中的错误称为 bug,但当你运行有错误或 bug 的代码时,有时你会得到这样的错误信息。

10:03\
有时我会得到错误信息,天哪,我不知道这是什么意思。
10:08\
幸运的是,你可以问聊天机器人如何修复代码。

10:14\
所以让我们把这行有 bug 的代码拿过来,让聊天机器人帮我们修复它。

10:19\
这是聊天机器人。

10:20\
我将清除对话,然后问它这段代码有什么问题,如何修复它?

10:27\
然后它给出了解释。

10:29\
代码中的字符串引号不匹配。

10:32\
这是修正后的代码 print。

10:35\
Hello Andrew。

10:37\
所以我实际上可以回到我的笔记本并编辑代码。

10:42\
我只需粘贴正确的答案。

10:43\
我们可以随意编辑它,然后运行它,这样就修复了它。

10:48\
所以发现并修复错误,也就是在计算机编程中发现和修复 bug,随着聊天机器人的出现,真的发生了变化,因为对于许多至少简单的错误,比如我们这里的小错别字,聊
天机器人非常擅长发现哪里出了问题。

11:06\
如果你感兴趣,你还可以使用聊天机器人向你解释错误信息。

11:13\
例如,如果我被问到这个错误信息是什么意思?

11:19\
然后粘贴你看到的错误信息,它实际上会给出一个相当不错的解释。

11:29\
现在你可能不知道其中一些术语的含义,比如什么是字符串或什么是扫描字符串。

11:37\
在这个短期课程结束时,你将学会很多词汇,比如 Python 中的字符串是什么,以帮助你理解这些信息。

11:46\
所以这几乎把我们带到了这节课的结尾。

11:50\
在你观看完这个视频后,进入下一课之前,我希望你完成一些这些小练习。

11:56\
所以我会做第一个。

11:57\
让我们看看 print blue。

12:00\
这是我最喜欢的颜色。

12:02\
这也是我儿子最喜欢的颜色,不是我女儿的。

12:05\
我希望你练习编写和运行打印语句,让它说你今天感觉如何。

12:12\
去吧,犯一个常见的错误。

12:13\
你知道,我们都会编写有错误或 bug 的代码。

12:16\
有时你也要这样做,甚至故意这样做,然后看看你是否能让聊天机器人修复错误。
12:22\
所以我希望你在这些练习中玩得开心。

12:26\
当你完成后,让我们进入下一课,我们将开始讨论数据,这是 AI 和 Python 程序的关键组成部分。

12:37\
我们下一课见。

12:47\
现在你已经运行了你的第一个程序,我需要与你分享一些学习编程的技巧。

12:54\
首先是尝试代码,暂停视频并运行代码。

13:00\
为了测试你对一行代码如何工作的理解,试着问自己一些问题,比如如果我省略一个引号会发生什么,或者如果我意外地有两个而不是一个右括号会发生什么?

13:15\
然后修改代码,运行它,看看你是否正确,给自己一些练习。

13:21\
我也鼓励你完成练习,我也鼓励你尽可能多地使用聊天机器人。

13:30\
把 AI 聊天机器人当作你的伙伴或编程伴侣,它非常了解 Python,耐心且只想帮助你。

13:38\
在学习这门课程时,你可能会想到一些“如果”或“为什么”的问题。

13:43\
如果我那样做会怎样?

13:44\
为什么是这样?

13:45\
尽管问聊天机器人尽可能多的问题。

13:49\
你也可以让你的聊天机器人解释代码,有时问它,这段代码是如何工作的?
13:55\
这是什么意思?

13:56\
这可能会帮助你理解一段代码实际上在做什么。

14:01\
这实际上也是专业软件开发人员今天所做的。

14:05\
当有一段代码我不理解时,我有时会把它粘贴到聊天机器人中,看看它是否能帮助我。

14:12\
当你编写和运行代码时,如果第一次没有成功,那完全没关系。

You might also like