
Arabic: 
 
المحتوى التالي هو
المقدمة بموجب الإبداعي
رخصة المشاع
دعمكم سوف يساعد معهد ماساتشوستس للتكنولوجيا
تواصل OpenCourseWare
تقديم جودة عالية التعليمية
الموارد مجانا.
للتبرع أو عرض
مواد إضافية من
المئات من دورات معهد ماساتشوستس للتكنولوجيا ، زيارة
معهد ماساتشوستس للتكنولوجيا OpenCourseWare في
ocw.mit.edu.
 
الأستاذ: مرحبا ، و
مرحبا بكم في 6.01.
أنا ديني فريمان.
أنا المحاضر.
شيء واحد يجب أن تعرفه
اليوم هو أن هناك
يد واحدة خارج.
يجب أن اخترت
الامر في طريقك في.
إنه متاح في أي منهما
من البابين.
 
ما أريد القيام به اليوم في هذا
المحاضرة الأولى هي في الغالب
التركيز على المحتوى.
ولكن قبل أن أفعل ذلك ، منذ ذلك الحين
6.01 قليلا من
بالطبع غير عادي ، أريد أن أعطي
أنت قليلا من
نظرة عامة واقول لكم قليلا
قليلا عن الإدارة

English: 
The following content is
provided under a Creative
Commons license.
Your support will help MIT
OpenCourseWare continue to
offer high quality educational
resources for free.
To make a donation or view
additional materials from
hundreds of MIT courses, visit
MIT OpenCourseWare at
ocw.mit.edu.
PROFESSOR: Hello, and
welcome to 6.01.
I'm Denny Freeman.
I'm the lecturer.
One thing you should know about
today is that there's a
single hand-out.
You should have picked
it up on your way in.
It's available at either
of the two doors.
What I want to do today in this
first lecture is mostly
focus on content.
But before I do that, since
6.01 is a little bit of an
unusual course, I want to give
you a little bit of an
overview and tell you a little
bit about the administration

English: 
of the course.
6.01 is mostly about
modes of reasoning.
What we would like you to get
out of this course is ways to
think about engineering.
We want to talk about how do you
design, how do you build,
how do you construct, how do you
debug complicated systems?
That's what engineers do, and
we're very good at it.
And we want to make you
very good at it.
We're very good at it.
And you know that from your
common, everyday experience.
Laptops are incredible.
As we go through the course,
you're going to see that
laptops incorporate things
from the tiniest, tiniest
level, things so small that
you can't see them.
They're microscopic.
The individual transistors are
not things that you can see.
We develop special tools for
you even to be able to

Arabic: 
الدورة.
 
6.01 هو في الغالب حول
طرق التفكير.
ما نود منك أن تحصل عليه
من هذه الدورة هو طرق ل
التفكير في الهندسة.
نريد التحدث عن كيف حالك؟
تصميم ، كيف يمكنك بناء ،
كيف يمكنك بناء ، كيف لك
تصحيح النظم المعقدة؟
هذا ما يفعله المهندسون و
نحن جيدون جدا في ذلك.
ونحن نريد أن نجعلك
جيد جدا في ذلك.
نحن جيدون جدا في ذلك.
وأنت تعرف ذلك من حسابك
تجربة شائعة يومية
أجهزة الكمبيوتر المحمولة لا تصدق.
ونحن نمضي في الدورة ،
أنت ذاهب لرؤية ذلك
أجهزة الكمبيوتر المحمولة دمج الأشياء
من الأصغر ، الأصغر
المستوى ، أشياء صغيرة جدا بحيث
لا يمكنك رؤيتهم.
انهم المجهرية.
الترانزستورات الفردية هي
ليس الأشياء التي يمكنك رؤيتها.
نحن نطور أدوات خاصة ل
أنت حتى تكون قادرة على

English: 
visualize them.
And yet, we conglomerate
billions of them into a system
that works relatively
reliably.
Now, I realize I'm going out on
a limb because when you say
things like that, then
things always fail.
But I'll go out on a limb and
say, for the most part, the
systems we construct
are very reliable.
We'd like you to know how you
think about making such a
complicated system and
making it reliable.
We want to tell you about how
you would model things.
How do you gain insight?
How do you get predictability?
How do you figure out how
something will work before
you've built it?
If you're limited to trying
out how things work by
actually constructing it,
you spend a lot of time
constructing things that
never make it.
We want to avoid that by
-- where we can --
making a model, analyzing the
model, making a prediction
from the model, and using that
prediction to build a better

Arabic: 
تصور لهم.
وحتى الآن ، نحن تكتل
مليارات منهم في النظام
هذا يعمل نسبيا
بثقة.
الآن ، أنا أدرك أنني أخرج
أحد الأطراف لأنه عندما تقول
أشياء من هذا القبيل ، إذن
الامور تفشل دائما.
لكنني سأخرج على أحد الأطراف و
يقول ، بالنسبة للجزء الاكبر ، و
النظم التي نبنيها
موثوقة جدا.
نود منك أن تعرف كيف أنت
التفكير في صنع مثل هذا
نظام معقد و
مما يجعلها موثوقة.
نريد أن نخبرك بكيفية ذلك
هل نموذج الأشياء.
كيف تكتسب بصيرة؟
كيف يمكنك الحصول على القدرة على التنبؤ؟
كيف يمكنك معرفة كيف
شيء سوف يعمل من قبل
لقد بنيت عليه؟
إذا كنت تقتصر على المحاولة
كيف تعمل الأشياء
في الواقع بناء عليه ،
تقضي الكثير من الوقت
بناء الأشياء التي
لا تجعله أبدا.
نحن نريد تجنب ذلك عن طريق
-- حيث يمكننا --
صنع نموذج ، تحليل
نموذج ، مما يجعل التنبؤ
من النموذج ، واستخدام ذلك
التنبؤ لبناء أفضل

Arabic: 
النظام في المحاولة الأولى.
 
نريد أن نخبرك بكيفية ذلك
لزيادة المادية
سلوك النظام عن طريق وضع
حساب في ذلك.
هذه تقنية قوية للغاية
هذا بشكل متزايد
شائع في أي شيء من
الميكروويف إلى الثلاجة.
نود منك أن تعرف
المبادئ
التي للقيام بذلك.
ونود منك أن تكون قادرة
لبناء النظم التي هي
قوي للفشل.
هذه فكرة أحدث.
إنه شيء الناس
جيدة جدا في.
إذا حاولنا القيام بشيء ما ،
ونحن نخطئ ، نحن
تعرف كيفية اصلاحها.
وغالبا ما يعمل الإصلاح.
نحن أقل جودة في القيام بذلك
في بناء الاصطناعي
النظم ، في الهندسة
الأنظمة.
ونود التحدث
حول المبادئ من قبل
التي يمكننا أن نفعل ذلك.
إذن الهدف من 6.01 هو ، إذن ،
حقا أن أنقل متميزة

English: 
system on the first try.
We want to tell you about how
to augment the physical
behavior of a system by putting
computation in it.
That's a very powerful technique
that is increasingly
common in anything from a
microwave to a refrigerator.
We'd like you to know
the principles
by which to do that.
And we'd like you to be able
to build systems that are
robust to failure.
That's a newer idea.
It's something that people
are very good at.
If we try to do something,
and we make a mistake, we
know how to fix it.
And often, the fix works.
We're less good at doing that
in constructing artificial
systems, in engineering
systems.
And we'd like to talk
about principles by
which we can do that.
So the goal of 6.01 is, then,
really to convey a distinct

English: 
perspective about how
we engineer systems.
Now, having said that, this is
not a philosophy course.
We are not going to make lists
of things to do if you want it
to be robust.
We're going to learn
to do things by
actually making systems.
This is an introductory
engineering course.
And so you're going
to build things.
The idea is going to be that in
constructing those things,
we've written the exercises so
that some of those important
themes become transparent.
So the idea is -- this is
introductory engineering.
You'll all make things.
You'll all get things to work,
and in the process of doing
that, learn something about the
bigger view of how quality
engineering happens.
So despite the fact that we're
really about modes of
reasoning, that will be
grounded in content.

Arabic: 
منظور حول كيف
نحن مهندس النظم.
الآن ، بعد قولي هذا ، هذا هو
ليس بالطبع الفلسفة.
لن نقوم بعمل قوائم
من الأشياء التي يجب القيام بها إذا كنت تريد ذلك
أن تكون قوية.
سوف نتعلم
لفعل الأشياء من قبل
فعلا صنع النظم.
هذا هو تمهيدية
بالطبع الهندسة.
و أنت ذاهب
لبناء الأشياء.
الفكرة ستكون في ذلك
بناء تلك الأشياء ،
لقد كتبنا التدريبات لذلك
أن بعض هؤلاء المهمين
المواضيع تصبح شفافة.
وبالتالي فإن الفكرة هي - هذا هو
الهندسة التمهيدية.
سوف تصنع جميع الأشياء.
ستحصل على أشياء للعمل ،
وفي عملية القيام به
ذلك ، تعلم شيئا عن
رؤية أكبر لكيفية الجودة
يحدث الهندسة.
 
لذلك على الرغم من أننا
حقا عن أوضاع
المنطق ، وهذا سيكون
ترتكز على المحتوى.

English: 
We selected the content very
broadly from across EECS.
EECS is an enormous endeavor.
We can't possibly introduce
everything
about EECS in one subject.
That's ridiculous.
However, we wanted to
give you a variety.
We wanted to give you a sense
of the variety of tasks that
you can use, that you can apply
the same techniques to.
So we want to introduce modes
of reasoning, and then show
you explicitly how you can use
those modes of reasoning in a
variety of contexts.
So we've chosen four, and we've
organized the course
around four modules.
First module is software
engineering, then signals and
systems, then circuits, then
probability and planning.
Even so, even having chosen
just four out of the vast
number of things we could have
chosen, there's no way we can
tell you adequately--
we can't give you an adequate
introduction to any of those
things either.
What we've chosen to do instead
is focus on key

Arabic: 
اخترنا المحتوى جدا
على نطاق واسع من جميع أنحاء EECS.
EECS هو مسعى هائل.
لا يمكننا تقديم
كل شىء
حول EECS في موضوع واحد.
هذا كلام سخيف.
ومع ذلك ، أردنا أن
أعطيك مجموعة متنوعة.
أردنا أن نقدم لك شعورا
مجموعة متنوعة من المهام التي
يمكنك استخدام ، والتي يمكنك تطبيقها
نفس التقنيات ل.
لذلك نحن نريد أن نقدم وسائط
من التفكير ، ومن ثم تظهر
أنت صراحة كيف يمكنك استخدامها
تلك الأساليب من التفكير في
مجموعة متنوعة من السياقات.
لذلك اخترنا أربعة ، ولقد اخترنا
نظمت الدورة
حوالي أربع وحدات.
الوحدة الأولى هي البرمجيات
الهندسة ، ثم الإشارات و
الأنظمة ، ثم الدوائر ، ثم
الاحتمال والتخطيط.
رغم ذلك ، حتى بعد أن اختار
فقط أربعة من الشاسعة
عدد الأشياء التي يمكن أن تكون لدينا
المختار ، لا توجد طريقة ممكنة
اقول لك بشكل كاف
لا يمكننا أن نقدم لك ما يكفي
مقدمة لأي من هؤلاء
الأشياء أيضا.
ما اخترنا القيام به بدلا من ذلك
هو التركيز على المفتاح

Arabic: 
مفاهيم ممثلة
من العلامات النجمية.
الفكرة ستكون نحن
اختيار واحد أو شيئين و
التركيز حقا على تلك بعمق
حتى تحصل على شامل
فهم ليس فقط كيف
التي تناسبها ، على سبيل المثال ،
سياق البرنامج
الهندسة ، ولكن أيضا كيف ذلك
مفهوم تشعب في
مناطق أخرى.
لاحظ أنني حاولت أن تختار
النجوم حتى هم
ضرب دوائر متعددة.
هذا ما نحن عليه
أحاول أن أفعل.
نحن نحاول ليس فقط
تقديم فكرة لك ، ولكن
كما تبين لك كيف يربط
لأفكار أخرى.
 
إذن الفكرة هي التركيز
على عدد قليل ، نأمل ، جدا
التطبيقات المختارة جيدا أن
سوف تثبت مجموعة متنوعة من
تقنيات قوية.
 
شعارنا ، الطريقة التي نعتزم بها
للذهاب حول تدريس هذا
الاشياء ، هي الممارسة ،
النظرية ، الممارسة.

English: 
concepts represented
by the asterisks.
The idea is going to be we
choose one or two things and
really focus on those deeply
so you get a thorough
understanding not only of how
that fits within, for example,
the context of software
engineering, but also how that
concept ramifies into
other areas.
Notice that I tried to choose
the stars so they
hit multiple circles.
That's what we're
trying to do.
We're trying to not only
introduce an idea to you, but
also show you how it connects
to other ideas.
So the idea, then, is to focus
on a few, we hope, very
well-chosen applications that
will demonstrate a variety of
powerful techniques.
Our mantra, the way we intend
to go about teaching this
stuff, is practice,
theory, practice.

Arabic: 
هناك التعليمية هائلة
الأدب الذي يقول--
شئت ام ابيت--
الناس يتعلمون بشكل أفضل متى
إنهم يفعلون أشياء.
لديك الكثير من الخبرة
مع ذلك.
لديك الكثير من الخبرة
على الجانب الآخر أيضا.
سأحاول نسيان الآخر
الجانب ، أو على الأقل محاولة المسح
من عقلك لحظات
للتركيز على أكثر الخاص بك
طرق التعلم الأساسية.
عندما كنت طفلا وأنت
كانوا يتعلمون الأول الخاص بك
اللغة ، أنت لم تتعلم كل شيء
قواعد القواعد الأولى.
أنت لم تتعلم كل الحروف
الأبجدية الأولى.
أنت لم تتعلم عن
تصريف الأفعال أولاً.
لقد تعلمت قليلا
قليلا عن اللغة.
لقد بدأت في استخدامه.
واجهت مشاكل.
لقد تعلمت أكثر من ذلك بقليل
عن اللغة.
تعلمت أن تذهب من الكلمات
مثل "تطعمني" إلى مستوى أعلى
مفاهيم ، مثل "يا ،
ماذا يوجد للعشاء؟"
وبالتالي فإن الفكرة هي أنك تعلمت
في تكرارية

English: 
There's an enormous educational
literature that says--
whether you like it or not--
people learn better when
they're doing things.
You have a lot of experience
with that.
You have a lot of experience
on the other side, too.
I'll try to forget the other
side, or at least try to wipe
it from your brain momentarily
to focus on your more
fundamental modes of learning.
When you were a kid and you
were learning your first
language, you didn't learn all
the rules of grammar first.
You didn't learn all the letters
of the alphabet first.
You didn't learn about
conjugating verbs first.
You learned a little
bit about language.
You started to use it.
You ran into problems.
You learned a little more
about language.
You learned to go from words
like "feed me" to higher level
concepts, like "Hey,
what's for dinner?"
So the idea is that you learned
it in an iterative

Arabic: 
عملية حيث تعلمت بعض
الاشياء ، جربتها ، علمت
بعض الأشياء الأخرى ، جربته.
وبنيت.
هناك أدب هائل
في التعليم الذي يقول هذا
بالضبط كيف نحن دائما
تعلم كل شيء.
وهذا هو الطريق هكذا
يركز بالطبع.
ما سنفعله هو ، على سبيل المثال ،
لهذا اليوم ، ونحن سوف
تعلم قليلا عن
هندسة البرمجيات.
ثم ، سنفعل جلستين معملين
اين انت فعلا
محاولة استخدام الأشياء
نحن نتكلم عن.
ثم ، سوف نعود للمحاضرة
وسيكون لدينا بعض
المزيد من النظريات حول كيف
سوف تفعل البرمجة.
وبعد ذلك ، يمكنك العودة إلى
مختبر والقيام ببعض الأشياء.
والأمل في ذلك
سياق ملموس ، سيكون لديك
تقدير أعمق
من الأفكار التي
نحن نحاول أن أنقل.
 
لذلك اسمحوا لي أن أقول لك قليلا
قليلا عن الوحدات الأربع
التي اخترناها.
الدورة ستكون
نظمت على أربع وحدات.
كل وحدة سوف يستغرق حوالي
ربع الدورة.
أول شيء سننظر إليه
هي هندسة البرمجيات.

English: 
process where you learned some
stuff, tried it out, learned
some more stuff, tried it out.
And it built up.
There's an enormous literature
in education that says that's
exactly how we always
learn everything.
And so that's the way this
course is focused.
What we will do is, for example,
for today, we'll
learn a little bit about
software engineering.
Then, we'll do two lab sessions
where you actually
try to use the things
we talk about.
Then, we'll come back to lecture
and we'll have some
more theory about how you
would do programming.
And then, you go back to the
lab and do some more stuff.
And the hope is that by this
tangible context, you'll have
a deeper appreciation
of the ideas that
we're trying to convey.
So let me tell you a little
bit about the four modules
that we've chosen.
The course is going to be
organized on four modules.
Each module will take about
one fourth of the course.
First thing we'll look at
is software engineering.

Arabic: 
كما قلت ، ليس لدينا وقت
للتركيز على ، أو حتى المسح ،
كل الأفكار الكبيرة في
هندسة البرمجيات.
انها كبيرة جدا.
لذلك سوف نركز بشكل ضيق
على واحد أو شيئين.
نود منك أن تعرف عنها
التجريد و نمطية
لأن هذا هو مثل
فكرة مهمة في
بناء النظم الكبيرة.
لذلك سوف
يكون تركيزنا.
في محاضرة اليوم ، سنبدأ
نتحدث عن وحدات
والتجريد في
النطاق الصغير.
كيف تؤثر على
الأشياء التي تكتبها
تعليمات إلى جهاز كمبيوتر؟
ولكن بحلول الأسبوع المقبل ، نحن ذاهبون
أن نتحدث عن كله
نطاق أكبر.
بحلول الأسبوع المقبل ، نحن ذاهبون إلى
نتحدث عن البناء
وحدات البرمجيات في
مستوى أعلى بكثير.
على وجه الخصوص ، سنتحدث عن
شيء نحن سوف
استدعاء آلة الدولة.

English: 
As I said, we don't have time
to focus on, or even survey,
all of the big ideas in
software engineering.
It's far too big.
So we're going to focus narrowly
on one or two things.
We'd like you to know about
abstraction and modularity
because that's such an
important idea in the
construction of big systems.
So that's going to
be our focus.
In today's lecture, we'll begin
talking about modularity
and abstraction at
the small scale.
How does it affect the
things you type as
instructions to a computer?
But by next week, we're going
to be talking about a whole
bigger scale.
By next week, we're going to
talk about constructing
software modules at a
much higher level.
In particular, we'll talk about
something that we'll
call a state machine.

English: 
A state machine is a thing
that works in steps.
On every step, the state machine
gets a new input.
Then, based on that input and
its memory of what's come
before, the state machine
decides to do something.
It generates an output.
And then, the process repeats.
We will see that that kind
of an abstraction --
state machines --
there's a way to think about
state machines that is
compositional that you can think
of as a hierarchy, just
as you can think of low-level
hierarchies within a language.
I'll say a lot more
about that today.
So the idea will be that once
you've composed a state
machine, you'll be able to join
two state machines and
have its behavior look just
like one state machine.
That's a way to get a more
complicated behavior by
constructing two simpler
behaviors.
That's what we want.
We want to learn tools that
let us compose complex

Arabic: 
آلة الدولة هي شيء
الذي يعمل في خطوات.
في كل خطوة ، آلة الدولة
يحصل على مدخلات جديدة.
ثم ، استنادا إلى هذا الإدخال و
ذاكرته لما يأتي
من قبل ، آلة الدولة
تقرر أن تفعل شيئا.
انه يولد الانتاج.
وبعد ذلك ، تتكرر العملية.
 
سوف نرى هذا النوع
التجريد -
آلات الدولة -
هناك طريقة للتفكير
آلات الدولة التي هي
التركيبية التي يمكنك التفكير
من التسلسل الهرمي ، فقط
كما يمكنك التفكير في المستوى المنخفض
التسلسلات الهرمية داخل اللغة.
سأقول أكثر من ذلك بكثير
عن ذلك اليوم.
وبالتالي فإن الفكرة ستكون ذلك مرة واحدة
لقد تتكون دولة
آلة ، سوف تكون قادرة على الانضمام
آلات الدولة و
يكون سلوكها تبدو فقط
مثل آلة دولة واحدة.
هذه طريقة للحصول على المزيد
سلوك معقد بواسطة
بناء اثنين أكثر بساطة
السلوكيات.
هذا ما نريده.
نحن نريد أن نتعلم الأدوات التي
دعونا نؤلف معقدة

English: 
behaviors out of simple
behaviors.
And the tangible model of
that will be the robot.
We will see how to write a
program that controls a robot
as a state machine.
That's certainly not the only
way you could control a robot.
And it's probably not the way
you would first think of it if
you took one course in
programming and somebody said
to you, go program the robot
to do something.
What we will see is that it's
a very powerful way to think
about it for exactly this
reason of modularity.
The bigger point that we will
make in thinking about this
first module is the idea
of, how do you
make systems modular?
How do you use abstraction to
simplify the design task?
And in particular, we will
focus on something
that we'll call PCAP.
When you think about a system,
we will always think about it
in terms of, what are
the primitives?

Arabic: 
سلوكيات بسيطة
السلوكيات.
والنموذج المادي لل
سيكون هذا الروبوت.
سوف نرى كيفية كتابة
البرنامج الذي يتحكم في الروبوت
كآلة الدولة.
هذا بالتأكيد ليس الوحيد
الطريقة التي يمكن أن تتحكم في الروبوت.
وربما ليس هو الطريق
سوف تفكر في الأمر أولاً إذا
كنت أخذت دورة واحدة في
البرمجة وقال شخص ما
لك ، اذهب برنامج الروبوت
لفعل شيء ما.
ما سنراه هو أنه
طريقة قوية جدا للتفكير
عن ذلك بالضبط لهذا
سبب الوحدة.
النقطة الأكبر التي سنقوم بها
جعل في التفكير في هذا
الوحدة الأولى هي الفكرة
كيف حالك؟
جعل أنظمة وحدات؟
كيف تستخدم التجريد ل
تبسيط مهمة التصميم؟
وعلى وجه الخصوص ، ونحن سوف
التركيز على شيء ما
أننا سوف ندعو PCAP.
عندما تفكر في نظام ،
سوف نفكر دائما في ذلك
من حيث ، ما هي
البدائية؟

Arabic: 
كيف تجمعهم؟
كيف مجردة أ
سلوك أكبر من
تلك السلوكيات الأصغر؟
وما هي الأنماط التي
هي مهمة لالتقاط؟
وبالتالي فإن النقطة الأكبر هي هذه الفكرة
من PCAP ، ونحن سوف
ثم إعادة النظر في كل
وحدة لاحقة.
حسنا ، الوحدة الثانية في وضع التشغيل
إشارات وأنظمة.
هذا أيضا مجال هائل.
لذلك لدينا فقط الوقت
لفعل شيء واحد.
الشيء الذي سنفعله هو نحن
سوف نفكر في منفصلة
ردود الفعل الوقت.
كيف تصنع نظاما
تدرك ما هو عليه
فعلت ذلك ، في المستقبل ،
يمكن أن تفعل أشياء مع
الوعي كيف وصلت إلى هناك؟
مثال جيد هو الروبوتية
توجيه.
وبالتالي فإن الفكرة ستكون ، حسنا ،
فكر فيما تفعله
عندما تقود سيارة.

English: 
How do you combine them?
How do you abstract a
bigger behavior from
those smaller behaviors?
And what are the patterns that
are important to capture?
So the bigger point is this idea
of PCAP, which we will
then revisit in every
subsequent module.
OK, second module is on
signals and systems.
That's also an enormous area.
So we only have time
to do one thing.
The thing that we will do is we
will think about discrete
time feedback.
How do you make a system that's
cognizant of what it's
done so that it, in the future,
can do things with
awareness of how it got there?
A good example is robotic
steering.
So the idea is going to be, OK,
think about what you do
when you're driving a car.

Arabic: 
والتفكير في كيف
سيقول الروبوت ل
افعل نفس الشيء
إليك قيادة ساذجة
الخوارزمية.
أنا لا أوصي به ، لكنه كذلك
تستخدم على نطاق واسع في بوسطن ،
على ما يبدو.
[ضحك]
أجد نفسي على يمين
حيث أود أن أكون.
اذا ماذا يجب أن أفعل؟
انعطف لليسار.
ما زلت على يمين
حيث أود أن أكون.
ماذا يجب أن أفعل؟
انعطف لليسار.
يا!
أنا بالضبط حيث يجب أن أكون.
ماذا يجب أن أفعل؟
اتجه للأمام مباشرة.
أوه ، هذه فكرة سيئة.
وما سنراه هو ذلك
يبحث الأبرياء تماما
الخوارزميات يمكن أن يكون رهيب
أداء.
ما سنفعله هو محاولة لجعل
مجردة من ذلك.
سنحاول صنع نموذج.
سنحاول التقاط ذلك في
الرياضيات حتى لا نحتاج إلى
بناء عليه لرؤية
سلوك سيء.
سنقوم بعمل نموذج.

English: 
And think about how you
would tell a robot to
do that same thing.
Here's a naive driving
algorithm.
I don't recommend it, but it's
widely used in Boston,
apparently.
[LAUGHTER]
I find myself to the right of
where I would like to be.
So what should I do?
Turn left.
I'm still to the right of
where I'd like to be.
What should I do?
Turn left.
Oh!
I'm exactly where I should be.
What should I do?
Go straight ahead.
Oh, that's a bad idea.
And what we'll see is that
perfectly innocent looking
algorithms can have horrendous
performance.
What we'll do is try to make
an abstraction of that.
We'll try to make a model.
We'll try to capture that in
math so that we don't need to
build it to see the
bad behavior.
We'll make a model.

Arabic: 
سوف نستخدم النموذج للتنبؤ
أن تلك الخوارزمية ينتن.
ولكن الأهم من ذلك ، سوف نستخدم
النموذج لمعرفة
الخوارزمية التي سوف تعمل بشكل أفضل.
في الواقع ، سنكون قادرين على ذلك
التوصل إلى حدود على كيف
حسنا مثل وحدة تحكم
يمكن أن تعمل ربما.
وبالتالي فإن التركيز في هذه الوحدة هو
ستكون ، كيف تجعل
نموذج للتنبؤ السلوك؟
كيف يمكنك تحليل النموذج
بحيث يمكنك تصميم أ
نظام أفضل؟
وبعد ذلك ، كيف يمكنك استخدام
نموذج والتحليل لجعل
نظام حسن التصرف؟
 
الوحدة الثالثة
على الدوائر.
مرة أخرى ، الدوائر ضخمة.
ليس لدينا وقت للحديث
عن كل الدوائر.
سنفعل أشياء بسيطة جدا.
سنركز اهتمامنا على
كيف تضيف حسي
القدرة على بالفعل
نظام معقد.
الفكرة ستكون ل
ابدأ بروبوت -
أعتقد أن هذا أكثر إشراقا -

English: 
We'll use the model to predict
that that algorithm stinks.
But more importantly, we'll use
the model to figure out an
algorithm that'll work better.
In fact, we'll even be able to
come up with bounds on how
well such a controller
could possibly work.
So the focus in this module is
going to be, how do you make a
model to predict behavior?
How do you analyze the model
so that you can design a
better system?
And then, how do you use the
model and the analysis to make
a well-behaved system?
The third module
is on circuits.
Again, circuits is huge.
We don't have time to talk
about all of circuits.
We'll do very simple things.
We'll focus our attention on
how you would add a sensory
capability to an already
complicated system.
The idea is going to be to
start with a robot--
I guess this is brighter--

English: 
start with our robots and design
a head for the robot.
The robot comes from the factory
with sonar sensors.
The sonar sensors are
these things.
There's eight of them.
They tell you how far away
something that reflects the
ultrasonic wave is.
As they come from the factory,
the robots can't sense light.
What you'll do is add
light sensors.
The goal is to make a system
to modify the robot so that
the robot tracks light.
That's a very simple goal.
And the way we'll that is to
augment the robot with a
simple sensor here, showed a
little more magnified here.
The idea is that this
is a LEGO motor.
The LEGO motor will turn this
relative to the attachment.
That's the robot head's neck.

Arabic: 
نبدأ مع الروبوتات لدينا والتصميم
رأس للروبوت.
الروبوت يأتي من المصنع
مع أجهزة استشعار السونار.
أجهزة الاستشعار سونار هي
هذه الاشياء.
هناك ثمانية منهم.
يقولون لك كيف بعيدا
شيء يعكس
الموجات فوق الصوتية هي.
لأنها تأتي من المصنع ،
الروبوتات لا تستطيع الشعور بالضوء.
ما عليك القيام به هو إضافة
مجسات الضوء.
الهدف هو جعل النظام
لتعديل الروبوت بحيث
الروبوت يتتبع الضوء.
هذا هدف بسيط للغاية.
والطريقة التي سنقوم بها هي
زيادة الروبوت مع
استشعار بسيط هنا ، وأظهر
أكثر قليلا مكبرة هنا.
والفكرة هي أن هذا
هو محرك ليغو.
سيحول محرك LEGO هذا
بالنسبة للمرفق.
هذا هو عنق رئيس الروبوت.

Arabic: 
لذلك سوف يكون الروبوت
قادرة على القيام بذلك.
وسوف يكون الروبوت عيون.
هذه هي محولات ضوئية ،
مقاوم للضوء ، في الواقع.
وبالتالي فإن الفكرة ستكون
أن هناك معلومات
المتاحة في تلك المجسات ل
معرفة أين هو ضوء ذلك
أنه يمكنك تتبع ذلك.
عملك سيكون ل
بناء دائرة -
هذا هذا الشيء -
الذي يتصل عبر الكابلات -
هذه الكابلات الحمراء و
الكابلات الصفراء
يربط عبر الكابلات
الى هذا الرأس.
سوف نعطيك الرأس.
عملك سيكون لجعل
الدائرة التي تحول
إشارة من photoresistor--
وهو في نسبة
إلى النور--
والأرقام حول كيفية تحويل
محرك للحصول على الرأس ل
مواجهة الضوء ثم السفينة
هذه المعلومات وصولا الى
روبوت للسماح للروبوت بدوره لها
عجلات للحصول على الجسم.
لذلك هو نوع من مثل الضوء
يأتي مشرق هنا.
ينظر الروبوت إليه ويقول:
أوه ، نعم ، هذا هو المكان الذي أنا فيه
تريد أن تكون.

English: 
So the robot will be
able to do this.
And the robot will have eyes.
These are photosensors,
photoresistors, actually.
So the idea is going to be
that there's information
available in those sensors for
figuring out where light is so
that you can track it.
Your job will be to
build a circuit--
that that's this thing--
that connects via cables--
these red cables and
yellow cables--
connects via cables
over to this head.
We'll give you the head.
Your job will be to make the
circuit that converts the
signal from the photoresistor--
which is in proportion
to light--
and figures out how to turn the
motor to get the head to
face the light and then ship
that information down to the
robot to let the robot turn its
wheels to get the body.
So it's kind of like the light
comes on bright over here.
The robot looks at it and says,
oh, yeah, that's where I
want to be.

English: 
So that's the idea in the third
module is to incorporate
new sensing capabilities
into the robot.
The final module is on
probability and planning.
And the idea there is to learn
about how you make systems
that are robust to uncertainty
and that can implement
complicated plans, that they,
too, are robust to
uncertainty.
So there's a number of things
that we will do, including
creating maps of spaces that the
robot doesn't understand,
telling the robot how to
localize itself, how if it
woke up suddenly in an
environment, it could figure
out where it is, how
to make a plan.
And as an example, I'll show you
the kind of system that we
will construct.
Here, the idea is that
we have a robot.
The robot knows where it is.

Arabic: 
هذه هي الفكرة في الثالث
الوحدة النمطية هي لدمج
قدرات الاستشعار الجديدة
في الروبوت.
الوحدة النهائية في وضع التشغيل
الاحتمال والتخطيط.
والفكرة هناك هي أن نتعلم
حول كيف تصنع النظم
التي هي قوية لعدم اليقين
ويمكن أن تنفذ
خطط معقدة ، أنهم ،
أيضا ، قوية ل
عدم اليقين.
لذلك هناك عدد من الأشياء
التي سنفعلها ، بما في ذلك
إنشاء خرائط للمساحات التي
الروبوت لا يفهم ،
إخبار الروبوت كيف
توطين نفسها ، كيف لو كان
استيقظت فجأة في
البيئة ، يمكن أن الرقم
أين هو ، كيف
لوضع خطة.
وكمثال ، سأريك
هذا النوع من النظام الذي نحن
سوف بناء.
هنا ، الفكرة هي ذلك
لدينا روبوت.
الروبوت يعرف أين هو.

English: 
Imagine there's a GPS in it.
There isn't, but imagine
there is.
So the robot knows where it
is, and it knows where it
wants to go.
That's the star.
But it has no idea what kind of
obstacles are in the way.
So if you were a robotic driver
in Boston, you know
that you started out at home and
you want to end up in MIT.
But there's these annoying
obstacles, they're called
people, that you should, in
principle at least, miss.
So that's kind of the idea.
So I know where I am.
I'm the robot.
I know where I am.
I know where I want to be.
And I'm going to summarize
that information here.
Where I am is purple.
Where I want to be is gold.
And I have a plan.
That's blue.
My plan's very simple.
I don't know anything about
anything other than I'm in
Waltham and I want to
go to Cambridge.
So blast east.
So I imagine that the
best way to do there

Arabic: 
تخيل أن هناك GPS في ذلك.
لا يوجد ولكن تخيل
يوجد.
لذلك يعرف الروبوت أين
هو ، ويعرف أين هو
يريد الذهاب.
هذا هو النجم.
ولكن ليس لديها فكرة عن أي نوع من
العقبات في الطريق.
إذا كنت سائقًا آليًا
في بوسطن ، أنت تعرف
أنك بدأت في المنزل و
تريد أن ينتهي في معهد ماساتشوستس للتكنولوجيا.
ولكن هناك هذه مزعج
العقبات ، يطلق عليهم
الناس ، التي يجب عليك ، في
مبدأ على الأقل ، ملكة جمال.
هذا هو نوع من الفكرة.
لذلك أنا أعرف أين أنا.
أنا الروبوت.
أنا أعرف أين أنا.
أنا أعرف أين أريد أن أكون.
وانا ذاهب الى تلخيص
هذه المعلومات هنا.
أين أنا أرجواني.
حيث أريد أن أكون الذهب.
ولدي خطة.
هذا أزرق.
خطتي بسيطة جدا.
أنا لا أعرف أي شيء عنه
أي شيء آخر غير أنا في
والثام وأنا أريد أن
اذهب إلى كامبريدج.
لذلك الانفجار الشرق.
 
لذلك أتصور أن
أفضل طريقة للقيام هناك

English: 
is a straight line.
OK, so now what I'm going to
do is turn on the robot.
The robot has now
made one step.
And I told you before about
these sonar sensors.
From the sonar sensors, the
robot has learned now that
there seems to be something
reflecting at each of these
black dots.
It got a reflection from
the black dots,
from the sonar sensors.
That means there's probably a
wall there, or a person, or
something that, in principle,
I should avoid.
And the red dots represent, OK,
the obstacle is so close I
really can't get there.
So I'm excluded from the red
spots because I'm too big.
The black spots seem
to be an obstacle.
The red spots seem to be
where I can't fit.
I still want to go from the
where I am, purple, to where I
want to be, gold.

Arabic: 
هو خط مستقيم.
حسناً ، الآن ماذا سأفعل
القيام به هو تشغيل الروبوت.
الروبوت لديه الآن
جعلت خطوة واحدة.
وقلت لك من قبل
هذه مجسات سونار.
من أجهزة الاستشعار السونار ، و
لقد تعلم الروبوت الآن ذلك
يبدو أن هناك شيء ما
مما يعكس في كل من هذه
نقاط سوداء.
حصلت على انعكاس من
النقاط السوداء ،
من أجهزة استشعار السونار.
وهذا يعني أن هناك ربما
الجدار هناك ، أو شخص ، أو
شيء ، من حيث المبدأ ،
يجب أن أتجنب.
 
والنقاط الحمراء تمثل ، حسنا ،
العقبة قريبة جدا أنا
حقا لا يمكن الوصول إلى هناك.
لذلك أنا مستبعد من الأحمر
البقع لأنني كبير جدا.
يبدو البقع السوداء
أن تكون عقبة.
البقع الحمراء ويبدو أن
حيث لا أستطيع الملاءمة.
ما زلت أريد أن أذهب من
حيث أنا ، الأرجواني ، إلى أين أنا
تريد أن تكون الذهب.

English: 
So what I do is I compute
the new plan.
OK then, I start to take
a step along that plan.
And as I'm stepping along, OK,
so now, I think that I can't
go from where I started
over to here.
I have to go around
this wall that I
didn't know about initially.
So now I just start driving.
And it looks fine, right?
I'm getting there, right?
Now, I know I can go
straight down here.
Oh, wait a minute.
There's another wall.
OK, what do I do now?
So as the robot goes along, it
didn't know when it started
what kinds of obstacles
it would encounter.
But as it's driving,
it learned.
Oh, that didn't work.
Start over!
So the idea is that this robot
is executing a very
complicated plan.
The plan has, in fact,
many sub-plans.
And the sub-plans all
involve uncertainty.

Arabic: 
فما أقوم به هو حسابي
الخطة الجديدة.
حسنا ، بعد ذلك ، أبدأ في اتخاذ
خطوة على طول هذه الخطة.
وبينما أتقدم ، حسناً ،
الآن ، أعتقد أنني لا أستطيع ذلك
اذهب من حيث بدأت
الى هنا.
يجب أن أتجول
هذا الجدار الذي أنا
لم أكن أعرف في البداية.
حتى الآن أنا فقط بدأت القيادة.
ويبدو بخير ، أليس كذلك؟
أنا الوصول إلى هناك ، أليس كذلك؟
الآن ، أنا أعلم أنني أستطيع أن أذهب
مباشرة إلى أسفل هنا.
أوه ، انتظر لحظة.
هناك جدار آخر.
حسنًا ، ماذا أفعل الآن؟
لذلك كما يسير الروبوت ، فإنه
لا أعرف متى بدأت
ما أنواع العقبات
سوف تواجه.
ولكن لأنه يقود ،
لقد تعلمت.
أوه ، هذا لم ينجح.
ابدأ من جديد!
وبالتالي فإن الفكرة هي أن هذا الروبوت
ينفذ جدا
خطة معقدة.
الخطة لديها ، في الواقع ،
العديد من الخطط الفرعية.
والخطط الفرعية جميع
تنطوي على عدم اليقين.

English: 
It didn't know where the walls
were when it started.
And when it's all done, it's
going to have figured out
where the walls were and--
provided there's a way--
presumably find the way to
negotiate the maze and get to
the destination.
So the idea, then, is that if
you were asked to write a
conventional kind of program for
solving that, it might be
kind of hard because
of the number of
contingencies involved.
What we will do is break down
the problem and figure out
simple and elegant ways
to deal not only with
uncertainty, but how do you
make complex plans.
So as I said, our primary
pedagogy is going to be
practice, theory, practice.
And so that ramifies in how
the course is organized.
So this is a quick map of some
of the aspects of the course.

Arabic: 
لم يعرف أين الجدران
كانت عندما بدأت.
وعندما يتم كل ذلك ،
سوف احسب
حيث كانت الجدران و--
شريطة أن يكون هناك طريقة -
يفترض العثور على الطريق ل
التفاوض في المتاهة والوصول إلى
الوجهة.
إذاً ، الفكرة هي أنه إذا
طلب منك أن تكتب
النوع التقليدي من البرنامج ل
حل ذلك ، قد يكون
نوع من الصعب ل
من عدد
حالات الطوارئ المعنية.
ما سنفعله هو الانهيار
المشكلة ومعرفة
طرق بسيطة وأنيقة
للتعامل ليس فقط مع
عدم اليقين ، ولكن كيف لك
وضع خطط معقدة.
 
هكذا قلت ، لدينا الابتدائية
علم أصول التدريس سيكون
الممارسة ، النظرية ، الممارسة.
وهكذا تشعب في كيف
يتم تنظيم الدورة.
هذه خريطة سريعة للبعض
من جوانب الدورة.

English: 
So we'll have weekly lectures.
It's lecture unintensive.
In total, there's only
13 lectures.
We'll meet once a week
here for lecture.
There's readings.
There's voluminous readings.
There's readings about every
topic that we will talk about.
And the readings were
specifically
designed for this course.
I highly recommend
that you become
familiar with the readings.
If you have a question after
lecture, it's probably there.
It's probably explained.
We will do online
tutor problems.
We sent you an email if you
pre-registered for the course.
So you may already
know about this.
The idea is going to be that
there's ways that you can
prepare for the course by doing
computer exercises.
And we will also use those same
kinds of exercises in all
of the class sessions.
We will have two kinds
of lab experiences.
Besides lecture, the other two
events that you have to attend

Arabic: 
لذلك سيكون لدينا محاضرات أسبوعية.
انها محاضرة غير مكثفة.
في المجموع ، هناك فقط
13 محاضرة.
سنلتقي مرة واحدة في الأسبوع
هنا للمحاضرة.
هناك قراءات.
هناك قراءات ضخمة.
هناك قراءات عن كل
الموضوع الذي سنتحدث عنه.
وكانت القراءات
على وجه التحديد
مصممة لهذه الدورة.
أنصح بشدة
أن تصبح
دراية القراءات.
إذا كان لديك سؤال بعد
محاضرة ، ربما هناك.
ربما أوضح.
 
سنفعل على الانترنت
مشاكل المعلم.
لقد أرسلنا لك رسالة بريد إلكتروني إذا كنت
مسجلة مسبقا للدورة.
لذلك قد بالفعل
تعرف عن هذا.
الفكرة ستكون ذلك
هناك طرق يمكنك
الاستعداد للدورة عن طريق العمل
تمارين الكمبيوتر.
ونحن سوف تستخدم أيضا تلك نفسها
أنواع التدريبات في كل شيء
من جلسات الفصل.
سيكون لدينا نوعين
من التجارب المعملية.
إلى جانب المحاضرة ، والآخران
الأحداث التي لديك لحضور

Arabic: 
هي مختبر البرمجيات
ومعمل التصميم.
هذا هو الجزء الممارسة.
حتى بعد أن تعلمت قليلا
قليلا عن نظرية عن طريق الذهاب
لإلقاء محاضرة ، عن طريق القيام
القراءة ، ثم تذهب إلى
مختبر وجرب بعض الأشياء.
نحن نسمي المختبر الأول
مختبر البرمجيات.
إنه مختبر قصير.
إنها ساعة ونصف.
أنت تعمل بشكل فردي.
يمكنك تجربة الأشياء.
تكتب برامج صغيرة.
يمكن أن تحقق المناهج التعليمية
برنامج لمعرفة ما إذا كان كل شيء على مايرام.
وفي المقام الأول ، التدريبات
في مختبر البرمجيات ومن المقرر
خلال مختبر البرمجيات.
ولكن في بعض الأحيان ، هناك سوف
أن تكون الأشياء الإضافية بسبب
بعد يوم أو يومين.
تواريخ الاستحقاق هي جدا
مكتوبة بوضوح
في تمارين المعلم.
مرة واحدة في الأسبوع ، هناك
مختبر التصميم.
هذه جلسة لمدة ثلاث ساعات في
التي تعمل مع شريك.
سبب الشريك
هو أن النية--
الفرق بين
مختبرات التصميم والبرنامج
المختبرات هي أن مختبرات التصميم تسأل
لك حل أكثر قليلا

English: 
are a software lab
and a design lab.
That's the practice part.
So after you learned a little
bit about the theory by going
to lecture, by doing the
reading, then you go to the
lab and try some things out.
We call the first lab
a software lab.
It's a short lab.
It's an hour and a half.
You work individually.
You try things out.
You write little programs.
The courseware can check the
program to see if it's OK.
And primarily, the exercises
in the software lab are due
during the software lab.
But on occasion, there will
be extra things due
a day or two later.
The due dates are very
clearly written
in the tutor exercises.
Once a week, there's
a design lab.
That's a three hour session in
which you work with a partner.
The reason for the partner
is that the intent--
the difference between the
design labs and the software
labs is that the design labs ask
you to solve slightly more

Arabic: 
أسئلة مفتوحة ، من النوع
السؤال الذي قد
ليس لديهم أدنى فكرة عما
نحن نسأل.
مفتوح العضوية ، وهذا النوع من الشيء
التي سوف يطلب منك القيام به
بعد التخرج.
تصميم النظام.
ماذا تقصد ، التصميم
النظام؟
 
وبالتالي فإن الفكرة هي أن العمل مع
شريك سوف اعطيكم
الثاني ، مصدر فوري لل
مساعدة وأكثر من ذلك بقليل
الثقة إذا لم يكن أحد منكم
يعرف الحل حتى يتسنى لك
ارفع يدك وقل ،
ليس لدي أدنى فكرة
ماذا يجري هنا.
وبالتالي فإن الفكرة هي أن مرة واحدة في
الأسبوع نفعل مختبر البرمجيات
بشكل فردي.
مرة واحدة في الأسبوع ، نقوم بعمل مختبر للتصميم ،
أكثر قليلا مفتوحة العضوية
مع الشركاء.
هناك القليل من الكتابة
الواجبات المنزلية ، أربعة المجموع.
انها ليست مقارنة بكثير
لمواضيع أخرى.
انها في الغالب ممارسة.
هناك مسابقة نانو ، فقط ل
تساعدك على مواكبة لجعل
تأكد من أنك لا تحصل عليه
بعيدا جدا وراء.
أول 15 دقيقة
من كل مختبر التصميم
يبدأ مع مسابقة نانو.

English: 
open-ended questions, the kind
of question that you might
have no clue what
we're asking.
Open-ended, the kind of thing
that you will be asked to do
after you graduate.
Design the system.
What do you mean, design
the system?
So the idea is that working with
a partner will give you a
second, immediate source of
help and a little more
confidence if neither of you
knows the solution so that you
raise your hand and say,
I don't have a clue
what's going on here.
So the idea is that once a
week we do a software lab
individually.
Once a week, we do a design lab,
a little more open-ended
with partners.
There's a little bit of written
homework, four total.
It's not much compared
to other subjects.
It's mostly practice.
There's a nano-quiz, just to
help you keep pace to make
sure that you don't get
too far behind.
The first 15 minutes
of every design lab
starts with a nano-quiz.

Arabic: 
وتهدف مسابقات نانو ل
أن تكون بسيطة إذا كنت قد اشتعلت
يصل ، إذا كنت حتى الآن.
وبالتالي فإن الفكرة هي أن تذهب إلى
مختبر التصميم ، أول شيء
أنت تفعل قليلا ، 15
دقيقة نانو مسابقة.
يستخدم اختبار نانو المعلم الكثير
مثل المعلم الواجبات المنزلية ،
يشبه المعلم بيثون.
وهذا هو المقصود
أن تكون بسيطة.
ولكن هذا يعني يرجى الحصول عليها
إلى مختبر التصميم في الوقت المحدد.
مسابقات نانو
يديرها البرنامج.
يبدأ الساعة عندما
يبدأ مختبر التصميم.
انها مهلة 15 دقيقة في وقت لاحق.
لذلك إذا أتيت متأخرة 10 دقائق ،
سيكون لديك 5 دقائق
لفعل شيء ما
خططنا لإعطاء
أنت 15 دقيقة ل.
 
سيكون لدينا أيضا الامتحانات
والمقابلات.
المقابلات تهدف إلى
كن محادثة فردية
حول كيف ذهبت المختبرات.
 
وسيكون لدينا اثنين من منتصف المدة
ونهائي.

English: 
The nano-quizzes are intended to
be simple if you've caught
up, if you're up to date.
So the idea is that you go to
design lab, the first thing
you do is a little, 15
minute nano-quiz.
The nano-quiz uses a tutor much
like the homework tutor,
much like the Python tutor.
And it's intended
to be simple.
But it does mean please get
to the design lab on time.
The nano-quizzes are
administered by the software.
It starts the hour when
the design lab starts.
It times out 15 minutes later.
So if you come 10 minutes late,
you will have 5 minutes
to do something that
we planned to give
you 15 minutes for.
We will also have exams
and interviews.
The interviews are intended to
be a one-on-one conversation
about how the labs went.
And we will have two mid-terms
and a final.

Arabic: 
لذلك هذا نوع من
اللوجستية.
الفكرة وراء الخدمات اللوجستية
الممارسة ، النظرية ، الممارسة.
تعال إلى المختبرات.
جرب الأشياء خارج.
تأكد من أنك تفهم.
تطوير رمز صغير.
اكتبه في.
معرفة ما اذا كان يعمل.
إذا كان يعمل ، أنت
على رأس الأشياء.
أنت جاهز للحصول على التالي
دفعة من المعلومات من
محاضرة وقراءات.
حسنا ، دعنا نذهب ، ودعونا
نتحدث عن التقنية
المواد في الوحدة الأولى
بالطبع ، في
وحدة البرمجيات.
نحن ركل المسار قبالة الحديث
حول هندسة البرمجيات ل
سببان.
نود منك أن تعرف عنها
هندسة البرمجيات.
انها مهمة بشكل لا يصدق
جزء من قسمنا.
انها مهمة بشكل لا يصدق
جزء من هندسة
بالتأكيد أي نظام ،
أي نظام حديث.
لكننا نود أيضًا أن تعرف
حول هذا الموضوع لأنه يوفر
طريقة مريحة للغاية للتفكير
عن - انها مريحة
لغة للتفكير في
قضايا التصميم ، والهندسة

English: 
So that's kind of
the logistics.
The idea behind the logistics is
practice, theory, practice.
Come to the labs.
Try things out.
Make sure you understand.
Develop a little code.
Type it in.
See if it works.
If it works, you're
on top of things.
You're ready to get the next
batch of information from the
lecture and readings.
OK, let's go on, and let's
talk about the technical
material in the first module
of the course, in
the software module.
We kick the course off talking
about software engineering for
two reasons.
We'd like you to know about
software engineering.
It's an incredibly important
part of our department.
It's an incredibly important
part of the engineering of
absolutely any system,
any modern system.
But we'd also like you to know
about it because it provides a
very convenient way to think
about-- it's a convenient
language to think about the
design issues, the engineering

Arabic: 
القضايا في كل الآخر
أجزاء من الفصل.
لذلك هو جيد جدا
مكان للبدء.
 
إذن ما سأفعله اليوم هو الكلام
عن بعض جدا
أبسط الأفكار حول التجريد
والوحدة في
ما أعتقد أنه من أدنى
مستوى التفاصيل.
كيف تفكر
التجريد و نمطية في
النطاق الصغير ، في
الفرد
خطوط مقياس رمز؟
كما قلت سابقًا ،
ونحن نتقدم ، أنظر
نمطية والتجريد
على نطاق واسع.
ولكن علينا أن نبدأ
مكان ما.
وسوف نبدأ
التفكير ، كيف حالك
التفكير في التجريد و
نمطية على نطاق صغير؟
ملاحظة خاصة حول
برمجة.
إذن ما نحاول القيام به هو ،
في الأسبوعين الأولين ،

English: 
issues in all the other
parts of the class.
So it's a very good
place to start.
So what I will do today is talk
about some of the very
simplest ideas about abstraction
and modularity in
what I think of as the lowest
level of granularity.
How do you think about
abstraction and modularity at
the micro scale, at
the individual
lines of code scale?
As I said earlier, we will,
as we progress, look at
modularity and abstraction
at the higher scale.
But we have to start
somewhere.
And we're going to start by
thinking about, how do you
think about abstraction and
modularity at the micro scale?
Special note about
programming.
So what we are trying to do is,
in the first two weeks,

English: 
ramp everybody up to some level
of software security,
where you feel comfortable.
So the first two weeks of this
course is intended to make you
comfortable with programming.
We don't assume you've done
extensive programming before.
We want you to become
comfortable
that you're not behind.
And that's the focus of the
first two weeks' exercises.
If you have little or no
previous background, if you
are uncomfortable, please do
the Python tutor exercises.
If you have not --
if you do not have a lot of
experience programming, if
you're uncomfortable with the
expectation that you can do
programming, do that first.
That takes priority over all the
other assignments during
the first two weeks.
In particular, if you're
uncomfortable, we will run a

Arabic: 
منحدر الجميع تصل إلى مستوى ما
أمن البرمجيات ،
حيث تشعر بالراحة
لذلك أول أسبوعين من هذا
يهدف بالطبع لتجعلك
مريح مع البرمجة.
نحن لا نفترض أنك فعلت
برمجة واسعة من قبل.
 
نريد منك أن تصبح
مريح
أنك لست وراء.
وهذا هو محور
تمارين الأسبوعين الأولين.
إذا كان لديك القليل أو لا
الخلفية السابقة ، إذا كنت
غير مريحة ، يرجى القيام به
تمارين المعلم بايثون.
إذا كنت لا تملك --
إذا لم يكن لديك الكثير من
تجربة البرمجة ، إذا
أنت غير مرتاح مع
توقع أنه يمكنك القيام به
البرمجة ، افعل ذلك أولاً.
يأخذ الأولوية على كل
مهام أخرى خلال
الأسبوعين الأولين.
على وجه الخصوص ، إذا كنت
غير مريح ، وسوف نقوم بتشغيل

Arabic: 
مساعدة بيثون الخاصة
جلسة يوم الاحد.
وإذا حضرت ذلك ، أنت
يمكن الحصول على تمديد مجانا.
 
الفكرة هي استكمال المعلم
تمارين تهدف إلى
تجعلك تشعر بالراحة ذلك
لديك البرنامج
خلفية لإنهاء
بقية الدورة.
افعل ذلك أولاً.
ونحن سوف يغفر الوقوع وراء
في أشياء أخرى بحيث أنت
تشعر بالراحة مع
برمجة.
إذا ، في نهاية أسبوعين ، أنت
لا تزال تشعر بعدم الارتياح ،
لدينا صفقة مع 6.00 ، و
بيثون فئة البرمجة ، ذلك
سوف تسمح لك بالتبديل
تسجيلك
من 6.01 إلى 6.00.
ولكن هذا ينتهي الحب
يوم.
[ضحك]
لذلك عليك أن تجعل عقلك
قبل عيد الحب إذا
تريد استخدام هذا الخيار.

English: 
special Python help
session on Sunday.
And if you attend that, you
can get a free extension.
The idea is completing the tutor
exercises is intended to
make you feel comfortable that
you have the software
background to finish the
rest of the course.
Do that first.
We will forgive falling behind
in other things so that you
feel comfortable with
programming.
If, at the end of two weeks, you
still feel uncomfortable,
we have a deal with 6.00, the
Python programming class, that
they will allow you to switch
your registration
from 6.01 to 6.00.
But that expires Valentine's
Day.
[LAUGHTER]
So you have to make up your mind
before Valentine's Day if
you'd like to use that option.

English: 
So the idea is we'd like you
to be comfortable with
programming.
If you haven't programmed
before, do the
Python tutor exercises.
Go to software lab.
Go to design lab, but work
on the tutor exercises.
The staff will help
you with them.
You can go to office hours.
There's office hours listed
on the home page.
You should try to become
comfortable, and you should
try to set as your goal --
I'm going to be comfortable
before Valentine's Day.
And if you're not, talk to a
staff member about that.
OK, so what do I want you to
know about programming?
Well, we're going
to use Python.
We selected Python because it's
very simple and because
it lets us illustrate some
very important ideas in
software engineering in
a very simple context.
That's the reason.

Arabic: 
وبالتالي فإن الفكرة هي أننا نود مثلك
أن تكون مريحة مع
برمجة.
إذا لم تكن مبرمجة
قبل ذلك
تمارين بيثون المعلم.
الذهاب إلى مختبر البرمجيات.
الذهاب إلى مختبر التصميم ، ولكن العمل
على تمارين المعلم.
الموظفين سوف تساعد
أنت معهم.
يمكنك الذهاب إلى ساعات العمل.
هناك ساعات مكتب المدرجة
على الصفحة الرئيسية.
يجب أن تحاول أن تصبح
مريح ، ويجب عليك
محاولة لتعيين هدفك -
سأكون مريحة
قبل عيد الحب.
وإذا لم تكن كذلك ، فتحدث إلى
موظف عن ذلك.
 
حسناً ، ماذا أريدك أن تفعل؟
تعرف عن البرمجة؟
حسنا ، نحن ذاهبون
لاستخدام بيثون.
اخترنا بيثون لأنه
بسيط جدا ولأن
يتيح لنا توضيح بعض
أفكار مهمة جدا في
هندسة البرمجيات في
سياق بسيط جدا.
هذا هو السبب.

Arabic: 
أحد الأسباب وراء ذلك
بسيط هو أنه
مترجم.
 
بعد بعض التهيئة ، و
سلوك بيثون هو السقوط
في حلقة مترجم.
حلقة المترجم هي ، اطلب من
المستخدم ما يود لي
للقيام ، وقراءة ما أنواع المستخدمين ،
معرفة ما هم عليه
نتحدث عن والطباعة
النتيجة ، كرر--
بسيط جدا.
ما يعنيه ذلك هو أنك
يمكن أن تتعلم عن طريق العمل.
 
هذه واحدة من نقاط
مختبر البرمجيات اليوم.
يمكنك ببساطة المشي
يصل إلى جهاز كمبيوتر ،
اكتب كلمة بيثون
ما تكتبه باللون الأحمر.
اكتب كلمة "بيثون". هذا
سوف يطالبك ، لذلك هذا
شيفرون ، وهذا يقول ، كنت
مثلك أن تقول لي
شيئا لفعله.
ليس لدي ما افعله.

English: 
One of the reasons that it's
simple is that it's an
interpreter.
After some initialization, the
behavior of Python is to fall
into an interpreter loop.
The interpreter loop is, ask the
user what he would like me
to do, read what the user types,
figure out what they're
talking about, and print
the result, repeat--
very simple.
What that means is that you
can learn by doing.
That's one of the points of
today's software lab.
You can simply walk
up to a computer,
type the word python--
what you type is in red.
Type the word "python." It
will prompt you, so this
chevron, that says, I'd
like you to tell me
something to do.
I have nothing to do.

English: 
If you type "2," Python tries
to interpret that.
In this particular case,
Python says, oh, I see.
That's a primitive data item.
That's an integer.
This person wants me to
understand an integer.
And so it will echo 2,
indicating that it thinks you
want it to understand
a simple integer.
Similarly, if you type 5.7,
it says, oh, I got that.
That's a float.
The person wants me
to remember a
floating point number.
And it will similarly
echo the float.
Now, of course, there's no
exact representation for
floats, right?
There's too many
of them, right?
There's a lot of them.
There's even more floats than
there are ints, right?
So it has an approximation.
So it will print its
approximation to the float
that it thinks you are
interested in.

Arabic: 
إذا قمت بكتابة "2" ، تحاول بيثون
لتفسير ذلك.
في هذه الحالة بالذات ،
بيثون يقول ، أوه ، أنا أرى.
هذا عنصر بيانات بدائي.
هذا عدد صحيح.
هذا الشخص يريدني
فهم عدد صحيح.
وهكذا سوف يردد صدى 2 ،
مشيرا إلى أنه يعتقد لك
تريد أن تفهم
عدد صحيح بسيط.
 
وبالمثل ، إذا قمت بكتابة 5.7 ،
تقول ، أوه ، حصلت على ذلك.
هذا تعويم.
الشخص يريدني
لنتذكر
رقم النقطة العائمة.
وسوف بالمثل
صدى تعويم.
الآن ، بالطبع ، لا يوجد
التمثيل الدقيق ل
يطفو ، أليس كذلك؟
هناك الكثير
منهم ، أليس كذلك؟
هناك الكثير منهم.
هناك حتى يطفو أكثر من
هناك النمل ، أليس كذلك؟
لذلك لديه تقريب.
لذلك سوف تطبع لها
تقريب لتعويم
أنه يعتقد أنك
مهتم ب.
 

Arabic: 
إذا كتبت سلسلة ، "مرحبًا"
سيقول ، أوه ، البيانات البدائية
هيكل ، سلسلة.
وسوف تطبع
هذه السلسلة.
وبالتالي فإن الفكرة هي واحدة من
ملامح بيثون التي تجعل
من السهل أن تتعلم حقيقة
انه مترجم.
يمكنك اللعب حولها.
يمكنك التعلم عن طريق العمل.
الآن ، بالطبع ، إذا كان فقط
الشيء الذي فعلته كان بيانات بسيطة
الهياكل ، فإنه
لا يكون مفيدا جدا.
 
وبالتالي فإن الشيء التالي أكثر تعقيدا
ما يمكن القيام به هو التفكير
مجموعات.
إذا قمت بكتابة "2 + 3" ، فإنه
يقول ، أوه ، حصلت عليه.
هذا الشخص مهتم
في مزيج.
يجب أن الجمع بين زائد
مشغل اثنين من النمل ، 2 و 3.
أوه ، وإذا فعلت ذلك ، إذا كنت كذلك
الجمع من قبل المشغل زائد
اثنين وثلاثة ، سأحصل على 5.
لذلك يطبع 5.
هذه هي الطريقة التي تعرف ذلك
يفسر "2 + 3" إلى 5.

English: 
If you type a string, "Hello,"
it'll say, oh, primitive data
structure, string.
And it'll print out
that string.
So the idea is one of the
features of Python that makes
it easy to learn is the fact
that it's interpreter based.
You can play around.
You can learn by doing.
Now, of course, if the only
thing it did was simple data
structures, it would
not be very useful.
So the next more complex thing
that it can do is think about
combinations.
If you type "2 + 3," it
says, oh, I got it.
This person's interested
in a combination.
I should combine by the plus
operator two ints, 2 and 3.
Oh, and if I do that, if I
combine by the plus operator
two and three, I'll get 5.
So it prints 5.
So that's a way you know that
it interprets "2 + 3" as 5.

English: 
Similarly here, except
I've mixed types.
"5.7 + 3," it says, oh, this
user wants me to apply the
plus operator on a
float and an int.
OK, well I'll upgrade
the int to a float.
I'll do the float version, and
I'll get this, which is its
representation of 8.7.
So the idea is that it will
first try to interpret what
you're saying as a
simple data type.
If that works, it prints the
result to tell you what it
thinks is going on.
It then will try to interpret
it as an expression.
And sometimes, the expressions
won't makes sense.
In particular, if you try to add
an int to a string, it's
going to say, huh?
And over the course of the first
two weeks, we hope that
you get familiar with
interpreting
this kind of mess.
That's Python's attempt to tell
you what it was trying to

Arabic: 
بالمثل هنا ، باستثناء
لقد أنواع مختلطة.
"5.7 + 3" ، هذا ، يقول ، هذا
المستخدم يريد مني تطبيق
زائد المشغل على
تطفو و int.
حسنا ، حسنا سأقوم بالترقية
الباحث عن تعويم.
سأفعل نسخة تعويم ، و
سأحصل على هذا ، والذي هو
تمثيل 8.7.
وبالتالي فإن الفكرة هي أنها سوف
أول محاولة لتفسير ما
أنت تقول ك
نوع البيانات البسيطة.
إذا كان هذا يعمل ، فإنه يطبع
نتيجة لأخبرك ما عليه
يعتقد يجري.
ثم سيحاول التفسير
ذلك كتعبير.
وأحيانا ، التعبيرات
لن يكون له معنى.
على وجه الخصوص ، إذا حاولت إضافة
كثافة العمليات إلى سلسلة ، هو
سوف أقول ، هاه؟
وعلى مدار الأول
أسبوعين ، نأمل ذلك
تتعرف على
تفسير
هذا النوع من الفوضى.
هذا هو محاولة بيثون أن أقول
أنت ما كان يحاول

Arabic: 
القيام به نيابة عنك ولا يمكن
معرفة ما
أنت تتكلم عن.
 
حسنا ، كان ذلك بسيطا.
لكنه يوضح بالفعل
هذا شيء جدا
المهم ، وهذا هو
فكرة تكوين.
هكذا تعمل بايثون
حقيقة أنه عندما قمت بإضافة 3 إلى
2 خرج 5 ، ما كنا
به كان يؤلف
معقد--
حسنا ، يحتمل أن تكون معقدة
(كان ذلك بسيطًا جدًا) -
يحتمل أن تكون معقدة
التعبيرات والحد منها
إلى بنية بيانات واحدة.
 
وهذا يعني ذلك ، في بعض
بمعنى ، هذه العملية ، 3
مرات 8 ، يمكن التفكير فيه
بالضبط نفس الشيء كما لو
كتب المستخدم في 24.

English: 
do on your behalf and can't
figure out what
you're talking about.
OK, so that was simple.
But it already illustrates
something that's very
important, and that's the
idea of a composition.
So the way Python works, the
fact that when you added 3 to
2 it came out 5, what we were
doing was composing
complicated--
well, potentially complicated
(that was pretty simple) --
potentially complicated
expressions and reducing them
to a single data structure.
And so that means that, in some
sense, this operation, 3
times 8, can be thought of as
exactly the same as if the
user had typed in 24.

Arabic: 
كلما استطعت أن تحل محلها
لتعبير معقد
شيء أبسط ، نقول أن
النظام هو التركيبية.
هذه فكرة قوية جدا.
على الرغم من أنها بسيطة ، إنها كذلك
فكرة قوية جدا.
إنها فكرة ذلك
جميعكم تعرفون.
لقد رأيته من قبل في
الجبر ، في الحساب.
لذلك في التعبيرات الحسابية ،
يمكنك التفكير في كيفية
مجموع اثنين من الأعداد الصحيحة هو كثافة العمليات.
 
هذا إغلاق.
هذا هو نوع من مزيج
هذا يجعل النظام
التركيبية وذاك
يوفر طبقة من
التفكير الهرمي بحيث ،
في رأسك ، على الرغم من ذلك
يقول 3 مرات 8 ، لا تحتاج
لنتذكر ذلك بعد الآن.
يمكنك القول ، أوه ، لأي
الأغراض التي تتبع ، وأنا قد
مجرد التفكير كذلك
3 مرات 8 بأنها
عدد صحيح واحد ، 24.
انها جزء من أنواع أخرى كثيرة
النظم ، على سبيل المثال ،

English: 
Whenever you can substitute
for a complex expression a
simpler thing, we say that the
system is compositional.
That's a very powerful idea.
Even though it's simple, it's
a very powerful idea.
And it's an idea that
you all know.
You've seen it before in
algebra, in arithmetic.
So in arithmetic expressions,
you can think about how the
sum of two integers is an int.
That's a closure.
That's a kind of a combination
that makes the system
compositional and that
provides a layer of
hierarchical thinking so that,
in your head, even though it
says 3 times 8, you don't need
to remember that anymore.
You can say, oh, for any
purposes that follow, I might
just as well think of
3 times 8 as being a
single integer, 24.
It's part of many other kinds
of systems, for example,

English: 
natural language.
The simplest example in natural
language is that you
can think about "Apples
are good as snacks".
"Apples" is a noun.
It's a plural noun.
Or you could substitute "Apples
and oranges", and it
makes complete sense within
that same structure.
So "Apples and oranges
are good as snacks".
The combination of "apples" and
"oranges" works in every
way from the point of view of
the grammar in the same way
that a simple noun,
"apples," worked.
What we would like to do is use
that idea as the starting
point for a more general
compositional system.
And a good way to think about
that is by way of names.
What if we had some sequence of
operations that we think is

Arabic: 
لغة طبيعية.
أبسط مثال في الطبيعي
اللغة هي أنك
يمكن التفكير في "التفاح
جيدة مثل الوجبات الخفيفة ".
"التفاح" هو الاسم.
انها اسم الجمع.
أو يمكنك استبدال "التفاح
والبرتقال "، وذلك
المنطقي الكامل في الداخل
نفس الهيكل.
لذلك "التفاح والبرتقال
جيدة مثل الوجبات الخفيفة ".
مزيج من "التفاح" و
"البرتقال" يعمل في كل
الطريق من وجهة نظر
القواعد بنفس الطريقة
هذا اسم بسيط ،
"التفاح" ، عملت.
ما نود القيام به هو استخدام
تلك الفكرة كبداية
نقطة لأكثر عمومية
نظام التركيب.
 
وطريقة جيدة للتفكير
هذا عن طريق الأسماء.
ماذا لو كان لدينا بعض تسلسل
العمليات التي نعتقد أنها

English: 
particularly important so that
we would like to somehow
canonize that so that,
subsequently, we can use that
sequence of operations easily?
Python provides a very
simple way to do it.
Every programming
language does.
It's not unique to Python.
But the idea is --
so here's an example.
"2 times 2" --
I'm squaring 2 and get
4. "3 times 3" --
I'm squaring 3, and
I'm getting 9.
"8 plus 4 times 8 plus 4",
I'm squaring "8 plus 4".
"8 plus 4", well, I can
think of that as 12.
I'm squaring 12, I'm
getting 144.
The thing I'm trying to
illustrate there is the notion
of squaring.
Squaring is a sequence of
operations that I would like
to be able to canonize as a
single entity so that, in
subsequent programs, I can
think of the squaring
operation as a single
operation just
like I think of times.

Arabic: 
أهمية خاصة بحيث
نود أن بطريقة أو بأخرى
تطويب ذلك ،
في وقت لاحق ، يمكننا استخدام ذلك
تسلسل العمليات بسهولة؟
يوفر بايثون جدا
طريقة بسيطة للقيام بذلك.
كل البرمجة
اللغة لا.
انها ليست فريدة من نوعها لبيثون.
لكن الفكرة هي -
لذلك هنا مثال.
"2 مرات 2" -
أنا تربيع 2 واحصل
4. "3 مرات 3" -
أنا تربيع 3 و
أنا أحصل على 9.
"8 زائد 4 مرات 8 زائد 4" ،
أنا تربيع "8 زائد 4".
"8 زائد 4" ، حسنا ، أستطيع
التفكير في ذلك إلى 12.
أنا تربيع 12 ، أنا
الحصول على 144.
الشيء الذي أحاول القيام به
توضيح أن هناك فكرة
من التربيع.
التربيع هو سلسلة من
العمليات التي أود
لتكون قادرة على تطهير باعتبارها
كيان واحد بحيث ، في
برامج لاحقة ، أستطيع
التفكير في التربيع
العملية باعتبارها واحدة
العملية فقط
كما أعتقد مرات.

Arabic: 
الطريقة التي نقول ذلك في بيثون
هو "تحديد مربع س ليكون
عودة س تربيع ".
 
ثم ، بعد أن فعلت ذلك
تعريف ، أستطيع أن أقول "مربع
من 6 "، والجواب هو 36.
حسنًا ، هذه خطوة صغيرة جدًا.
لكنه يوضح جدا
نقطة مهمة ، الفكرة
كون ذلك يوفر بيثون
منشأة التركيبية.
 
وانها هرمية.
 
بعد تحديد مربع ، يمكنني استخدامها
مربع كما لو كان
كان عامل بدائي.
ويمكنني أن استخدم المربع لتحديد
عمليات أعلى مستوى.
لذلك على سبيل المثال ، ماذا لو كنت
المهتمين في القيام بالكثير من
مبالغ المربعات؟
قل أنا فيثاغورس ، أليس كذلك؟
لذلك قد ترغب في إضافة
مربع 2 و مربع
4 للحصول على 20 ، أو مربع
من 3 مع

English: 
The way we say that in Python
is "define square of x to be
return x squared".
Then, having made that
definition, I can say "square
of 6", and the answer is 36.
OK, this is a very small step.
But it illustrates a very
important point, the idea
being that Python provides
a compositional facility.
And it's hierarchical.
Having defined square, I can use
square just as though it
were a primitive operator.
And I can use square to define
higher level operations.
So for example, what if I were
interested in doing lots of
sums of squares?
Say I'm Pythagoreas, right?
So I might want to add the
square of 2 and the square of
4 to get 20, or the square
of 3 with the

Arabic: 
مربع من 4 للحصول على 25.
باستخدام هذه الفكرة البسيطة
تكوين ، يمكننا كتابة
برنامج جديد ، sumOfSquares.
sumOfSquares يأخذ اثنين
الحجج ، س وص.
ويعود مربع
س ومربع ذ.
SumOfSquares لا
يهتم كيف
أنت تحسب المربع.
انها تثق في أن مربع يعرف
كيف يتم فعل ذلك.
وبالتالي فإن العمل أصغر.
والفكرة هي تلك الساحة
يعتني
تربيع الأرقام الفردية.
sumOfSquares ليس من الضروري أن
معرفة كيفية تربيع الأرقام.
انها تحتاج فقط لمعرفة كيفية
اصنع مجموع المربعات.
لذلك ما قمنا به هو أننا
كسر مهمة ، والتي لم تكن كذلك
معقدة للغاية ، ولكن كله
الفكرة هرمية.
لقد اتخذنا مشكلة وكسر
الى قطعتين.
نحن في مشكلة في
كيف يمكنك أن تفعل مربع ، و

English: 
square of 4 to get 25.
Using that simple idea of
composition, we can write a
new program, sumOfSquares.
sumOfSquares takes two
arguments, x and y.
And it returns the square of
x and the square of y.
SumOfSquares doesn't
care about how
you compute the square.
It trusts that square knows
how to do that.
So the work is smaller.
The idea is that square
takes care of
squaring single numbers.
sumOfSquares doesn't have to
know how to square numbers.
It just needs to know how to
make a sum of squares.
So what we've done is we've
broken a task, which was not
very complicated, but the whole
idea is hierarchical.
We've taken a problem and broken
it into two pieces.
We factored the problem into
how do you do a square, and

Arabic: 
كيف يمكنك جمع المربعات.
 
والفكرة ، إذن ، هي أن هذا
الهيكل الهرمي هو
وسيلة لبناء مجمع
أنظمة من أجزاء أبسط.
 
هذه هي فكرة كيف أنت
سوف بناء البرامج التي هي
التركيبية.
 
يوفر بايثون أيضا أداة
لصنع قوائم ، لصنع
هياكل البيانات التي
هي التركيبية.
 
الأكثر بدائية هي قائمة.
في بيثون ، يمكنك ذلك
تحديد قائمة.
فيما يلي قائمة بالأعداد الصحيحة.
هكذا تقول القائمة ، بداية
قائمة ، نهاية
قائمة ، عناصر القائمة.
So there's five elements
in the list, the
integers 1, 2, 3, 4, 5.

English: 
how do you sum squares.
And the idea, then, is that this
hierarchical structure is
a way of building complex
systems out of simpler parts.
So that's the idea of how you
would build programs that are
compositional.
Python also provides a utility
for making lists, for making
data structures that
are compositional.
The most primitive is a list.
So in Python, you can
specify a list.
Here's a list of integers.
So the list says, beginning
list, end of
list, elements of list.
So there's five elements
in the list, the
integers 1, 2, 3, 4, 5.

Arabic: 
 
Python doesn't care what the
elements of a list are.
We'll see in a minute that
that's really important.
But for the time being, the
simplest thing that you can
imagine is a heterogeneous
قائمة.
It's not critical that the list
contain just integers.
Here's a list that contains
an int, a string,
an int, and a string.
Python doesn't care.
It's a list that has
four elements.
The first element's an int.
The second element's a
string, et cetera.
Here's an even more
complex example.
Here's a list of lists.
 
How many elements are
in that list?
ثلاثة.
How many elements are
in that list?
So the idea is that you can
build more complex data
structures out of simple ones.

English: 
Python doesn't care what the
elements of a list are.
We'll see in a minute that
that's really important.
But for the time being, the
simplest thing that you can
imagine is a heterogeneous
list.
It's not critical that the list
contain just integers.
Here's a list that contains
an int, a string,
an int, and a string.
Python doesn't care.
It's a list that has
four elements.
The first element's an int.
The second element's a
string, et cetera.
Here's an even more
complex example.
Here's a list of lists.
How many elements are
in that list?
Three.
How many elements are
in that list?
So the idea is that you can
build more complex data
structures out of simple ones.

English: 
That's the idea of compositional
factoring
applied to data.
Just like it was important when
we were thinking about
procedures, to associate
names with procedures--
that's what "def" did--
we can also think about
associating names with data
structures.
And that's what we use something
that Python calls a
variable for.
So I can say "b is 3".
And that associates the data
item, 3, with the label, b.
I can say, "x is 5 times 2.2".
Python will figure out
what I mean by the
expression on the right.
It'll figure out that I'm
composing by using the star
operator, which is multiply, an
integer and a float, which
will give me a float.

Arabic: 
That's the idea of compositional
factoring
applied to data.
 
Just like it was important when
we were thinking about
procedures, to associate
names with procedures--
that's what "def" did--
we can also think about
associating names with data
structures.
And that's what we use something
that Python calls a
variable for.
So I can say "b is 3".
And that associates the data
item, 3, with the label, b.
I can say, "x is 5 times 2.2".
Python will figure out
what I mean by the
expression on the right.
It'll figure out that I'm
composing by using the star
operator, which is multiply, an
integer and a float, which
will give me a float.

Arabic: 
The answer to that's going to
be a floating point number.
And it will assign a label, x,
to that floating point number.
You can have a more complicated
list, a data
structure, and associate
the name y with it.
Then, having associated the name
y, you get many of the
same benefits of associating a
name with a data structure
that we got previously
in associating a
name with an operation.
So we can say, y(0).
And what that means is, what's
the zero-th elements of the
data structure, y?
So the zero-th element of
the data structure,
y, is a list, [1, 2, 3].
 
Python has some funky
notations.
The -1 element is
the last one.
So the -1th element
of y is [7, 8, 9].
 
And it's completely
hierarchical.

English: 
The answer to that's going to
be a floating point number.
And it will assign a label, x,
to that floating point number.
You can have a more complicated
list, a data
structure, and associate
the name y with it.
Then, having associated the name
y, you get many of the
same benefits of associating a
name with a data structure
that we got previously
in associating a
name with an operation.
So we can say, y(0).
And what that means is, what's
the zero-th elements of the
data structure, y?
So the zero-th element of
the data structure,
y, is a list, [1, 2, 3].
Python has some funky
notations.
The -1 element is
the last one.
So the -1th element
of y is [7, 8, 9].
And it's completely
hierarchical.

Arabic: 
If I asked for the -1 element
of y, I get [7, 8, 9].
But then, if I asked for the
first element of that
result, I get 8.
حسنا؟
Everything is clear?
 
OK, just to make sure everything
is clear, I want to
ask you a question.
But to kick off the idea of
working together, I'd like you
to think about this question
with your neighbor.
So before thinking about this
question, everybody stand up.
Introduce yourself
to your neighbor.

English: 
If I asked for the -1 element
of y, I get [7, 8, 9].
But then, if I asked for the
first element of that
result, I get 8.
OK?
Everything is clear?
OK, just to make sure everything
is clear, I want to
ask you a question.
But to kick off the idea of
working together, I'd like you
to think about this question
with your neighbor.
So before thinking about this
question, everybody stand up.
Introduce yourself
to your neighbor.

English: 
[AUDIENCE TALKS]
So now, I'd like you to each
discuss with your neighbor the
list that is best represented
by which of the following
figures, 1, 2, 3, 4, or 5,
or none of the above.
And in 30 seconds, I'm going
to ask everybody to raise a
hand with a number of fingers
indicating the right answer.

Arabic: 
[AUDIENCE TALKS]
So now, I'd like you to each
discuss with your neighbor the
list that is best represented
by which of the following
figures, 1, 2, 3, 4, or 5,
or none of the above.
And in 30 seconds, I'm going
to ask everybody to raise a
hand with a number of fingers
indicating the right answer.

English: 
You're allowed to talk.
That's the whole point
of having a partner.

Arabic: 
You're allowed to talk.
That's the whole point
of having a partner.

Arabic: 
[AUDIENCE TALKS]
حسنا.
 
I'd like everybody now
to raise their hand.
Put up the number of fingers
that show the answer.
And I want to tally.
 
رائع!
Everybody gets it.
OK, so which one do you like?
AUDIENCE: 3.
PROFESSOR: 3 --

English: 
[AUDIENCE TALKS]
OK.
I'd like everybody now
to raise their hand.
Put up the number of fingers
that show the answer.
And I want to tally.
Fantastic!
Everybody gets it.
OK, so which one do you like?
AUDIENCE: 3.
PROFESSOR: 3 --

Arabic: 
why do you like three.
Somebody explain this to me?
It just looks good?
Its pattern recognition.
What's good about 3?
AUDIENCE: It shows
the compositional
element of the list.
PROFESSOR: Compositional?
What is the compositional
element in the pictures?
 
What represents what?
OK, 'a' represents a.
هذا سهل جدا ، أليس كذلك؟
So that takes care of the
bulk of the figures.
What's the blue lines
represent?
 
Someone else?
I didn't quite understand.
AUDIENCE: The angles represent
like a list.
PROFESSOR: They represent
a list.
Where is the list
on the figures?
AUDIENCE: The vertex?
PROFESSOR: The vertex.
The vertices are lists.
So in 3 --

English: 
why do you like three.
Somebody explain this to me?
It just looks good?
Its pattern recognition.
What's good about 3?
AUDIENCE: It shows
the compositional
element of the list.
PROFESSOR: Compositional?
What is the compositional
element in the pictures?
What represents what?
OK, 'a' represents a.
That's pretty easy, right?
So that takes care of the
bulk of the figures.
What's the blue lines
represent?
Someone else?
I didn't quite understand.
AUDIENCE: The angles represent
like a list.
PROFESSOR: They represent
a list.
Where is the list
on the figures?
AUDIENCE: The vertex?
PROFESSOR: The vertex.
The vertices are lists.
So in 3 --

English: 
at the highest level, we have a
list that's composed of how
many elements?
2.
The first element
of that list is?
AUDIENCE: a.
PROFESSOR: And the second
element of that list is?
AUDIENCE: Another list.
PROFESSOR: Another list.
That's the hierarchical
part, right?
That second list has
how many elements?
AUDIENCE: 2.
PROFESSOR: Fine,
good, recurse.
You got it.
What is the list represented
by number 2?
A single list with
five elements.
Square bracket, a, comma, b,
comma, c, comma, d, comma, e,
square bracket, right?
What is the list represented
by that one?
AUDIENCE: Not a list.
PROFESSOR: Agh!
It's not a list!
What is it?
Who knows?
AUDIENCE: Looking
at the variable
names, it defines them.
You have variables.
You have a variable a, that
defines a list that contains

Arabic: 
at the highest level, we have a
list that's composed of how
many elements?
2.
The first element
of that list is?
AUDIENCE: a.
PROFESSOR: And the second
element of that list is?
AUDIENCE: Another list.
PROFESSOR: Another list.
That's the hierarchical
part, right?
That second list has
how many elements?
AUDIENCE: 2.
PROFESSOR: Fine,
good, recurse.
لك ذالك.
What is the list represented
by number 2?
 
A single list with
five elements.
Square bracket, a, comma, b,
comma, c, comma, d, comma, e,
square bracket, right?
What is the list represented
by that one?
AUDIENCE: Not a list.
PROFESSOR: Agh!
It's not a list!
ما هذا؟
من تعرف؟
AUDIENCE: Looking
at the variable
names, it defines them.
You have variables.
You have a variable a, that
defines a list that contains

Arabic: 
b, and the variable, c, that
defines another list that
contains d.
PROFESSOR: So we could
make that a variable.
If we said a is a variable that
comprises b and c, then
we have the problem of how
we're going to associate
variables and elements into
this list, right?
So the weird thing about
this one and, let's
see, that one's weird.
This one's also kind of weird.
This one's weird because we're
giving names to lists in a
fashion that's not showed
up here, right?
That's not to say you couldn't
invent a meaning.
It's just that it doesn't
map very well to that
representation.
Similarly over here, we seem to
be giving the name b to the
element a, and then the name
c to the element b.
What on earth are you
talking about?
It's not clear what we're
doing their either.
So the point is to get you
thinking about the abstract
representation of lists and how
that maps into a complex
data structure.

English: 
b, and the variable, c, that
defines another list that
contains d.
PROFESSOR: So we could
make that a variable.
If we said a is a variable that
comprises b and c, then
we have the problem of how
we're going to associate
variables and elements into
this list, right?
So the weird thing about
this one and, let's
see, that one's weird.
This one's also kind of weird.
This one's weird because we're
giving names to lists in a
fashion that's not showed
up here, right?
That's not to say you couldn't
invent a meaning.
It's just that it doesn't
map very well to that
representation.
Similarly over here, we seem to
be giving the name b to the
element a, and then the name
c to the element b.
What on earth are you
talking about?
It's not clear what we're
doing their either.
So the point is to get you
thinking about the abstract
representation of lists and how
that maps into a complex
data structure.

Arabic: 
That was the whole point.
OK, so we've talked about,
then, four things so far.
How do you think about
operations in a
hierarchical fashion.
And the idea was composition.
We think about composing simple
operations to make
bigger, compound operations.
That's a way of saying, there's
this set of operations
that I want to call foo.
So every time I do this
complicated thing that has
three pages of code,
that's one foo.
And that's a way that we can
then combined foos in some
other horribly complicated
way to make big foos.
So the idea is composition.
That's the first idea.
The second is associating a name
with that composition.
That's what "def" does--
define name, name of a
sub-routine.
So we thought about composing
operations,
associating names with them.

English: 
That was the whole point.
OK, so we've talked about,
then, four things so far.
How do you think about
operations in a
hierarchical fashion.
And the idea was composition.
We think about composing simple
operations to make
bigger, compound operations.
That's a way of saying, there's
this set of operations
that I want to call foo.
So every time I do this
complicated thing that has
three pages of code,
that's one foo.
And that's a way that we can
then combined foos in some
other horribly complicated
way to make big foos.
So the idea is composition.
That's the first idea.
The second is associating a name
with that composition.
That's what "def" does--
define name, name of a
sub-routine.
So we thought about composing
operations,
associating names with them.

Arabic: 
We composed data in terms of
lists, and we associated names
with those lists in terms
of variables.
The next thing we want to think
about is a higher order
construct where we would like to
conglomerate into one data
structure both data
and procedures.
Python has a concept called a
class that lets us do that.
In Python, you make a new class
by saying to the Python
prompt, I want a new class
called Student.
And then, under Student, there
is this thing which we will
call an attribute.
An attribute to a class is
simply a data item associated
with the class.
And a method--
a method is just a
procedure that is
associated with the class.
So there's this single item
class called Student that has

English: 
We composed data in terms of
lists, and we associated names
with those lists in terms
of variables.
The next thing we want to think
about is a higher order
construct where we would like to
conglomerate into one data
structure both data
and procedures.
Python has a concept called a
class that lets us do that.
In Python, you make a new class
by saying to the Python
prompt, I want a new class
called Student.
And then, under Student, there
is this thing which we will
call an attribute.
An attribute to a class is
simply a data item associated
with the class.
And a method--
a method is just a
procedure that is
associated with the class.
So there's this single item
class called Student that has

English: 
one piece of data, its
attribute, school, and one
procedure, which is the method
calculateFinalGrade.
So then, this is the kind of
data structure you might
imagine that a registrar
would have.
It's a way to associate.
So the idea here is that
everybody here is a student.
They all have a school.
And they all have a way of
calculating their final grade.
That's a very narrow view that
maybe a registrar would have.
So classes, having defined
them, we can then use the
class to define an instance.
So an instance is a data
structure that inherits all of
the structure from the class but
also provides a mechanism
for having specific data
associated with the instance.

Arabic: 
one piece of data, its
attribute, school, and one
procedure, which is the method
calculateFinalGrade.
So then, this is the kind of
data structure you might
imagine that a registrar
would have.
It's a way to associate.
So the idea here is that
everybody here is a student.
They all have a school.
And they all have a way of
calculating their final grade.
That's a very narrow view that
maybe a registrar would have.
So classes, having defined
them, we can then use the
class to define an instance.
So an instance is a data
structure that inherits all of
the structure from the class but
also provides a mechanism
for having specific data
associated with the instance.

English: 
So in Python, I say
Mary is a student.
By mentioning the name of the
class and putting parenthesis
on it, I say, give me an
instance of the student.
So now, Mary is a name
associated with an instance of
the class, Student.
John is similarly an instance
of the class, Student.
So both Mary and John
have schools.
In fact, they're
both the same.
The school of Mary and the
school of John are both MIT.
But I can extend the instance
of Mary to include a new
attribute, the section number,
so that Mary's section number
is 3 and John's section
number is 4.
So this provides a way--
it's a higher-order concept.
We thought of a way to aggregate
operations into

Arabic: 
So in Python, I say
Mary is a student.
By mentioning the name of the
class and putting parenthesis
on it, I say, give me an
instance of the student.
So now, Mary is a name
associated with an instance of
the class, Student.
John is similarly an instance
of the class, Student.
So both Mary and John
have schools.
In fact, they're
both the same.
The school of Mary and the
school of John are both MIT.
But I can extend the instance
of Mary to include a new
attribute, the section number,
so that Mary's section number
is 3 and John's section
number is 4.
So this provides a way--
it's a higher-order concept.
We thought of a way to aggregate
operations into

English: 
complicated operation, data
into complicated data.
Classes aggregate data
and operations.
Classes allow us to create
a structure and
then generate instances.
And then the instances have
access to those features that
were defined in the class, but
also have the ability to
define their own unique
attributes and methods.
You can also use a class
to define a subclass.
So here, I'm defining the
subclass, Student601.
All Student601s are members
of the class, Student.
The reverse is not true.
So all Student601 entities
inherit everything that a
Student has.
But all 601 students share
some other things.
Besides having a school which
all students have, 601
students also have a lecture
day, a lecture time, and a
method for calculating
tutor scores.

Arabic: 
complicated operation, data
into complicated data.
Classes aggregate data
and operations.
Classes allow us to create
a structure and
then generate instances.
And then the instances have
access to those features that
were defined in the class, but
also have the ability to
define their own unique
attributes and methods.
You can also use a class
to define a subclass.
So here, I'm defining the
subclass, Student601.
All Student601s are members
of the class, Student.
The reverse is not true.
So all Student601 entities
inherit everything that a
Student has.
But all 601 students share
some other things.
Besides having a school which
all students have, 601
students also have a lecture
day, a lecture time, and a
method for calculating
tutor scores.
 

Arabic: 
Not all students have a method
for calculating tutor scores.
But members of the class
Student601 do.
 
So this, again, represents a
way of organizing data and
operations in a way that makes
it easier to compose higher,
bigger, more complex
structures.
 
The final thing that I want
to talk about today is the
specific, gory details for how
Python manages the association
between names and entities.
We've already seen
two of those.
Naming operations is via "def."
And it gives rise to
the name of a procedure.
Variables are ways of naming
data structures.
Now, we've seen a way
of naming classes.

English: 
Not all students have a method
for calculating tutor scores.
But members of the class
Student601 do.
So this, again, represents a
way of organizing data and
operations in a way that makes
it easier to compose higher,
bigger, more complex
structures.
The final thing that I want
to talk about today is the
specific, gory details for how
Python manages the association
between names and entities.
We've already seen
two of those.
Naming operations is via "def."
And it gives rise to
the name of a procedure.
Variables are ways of naming
data structures.
Now, we've seen a way
of naming classes.

Arabic: 
And in fact, it's helpful
if you understand.
So Python associates names and
entities in a very simple,
straightforward fashion.
And if you know the ground
rules, it makes it very easy
to deal with.
And if you don't know the ground
rules, it makes it very
hard to deal with.
So what's the ground rules?
Here's the gory details.
So Python associates names with
values in what Python
calls a binding environment.
An environment is just a
list that associates
a name and an entity.
So if you were to type b
equals 3 what Python is
actually doing is it's building
this environment.
When you type b equals 3, it
adds to the environment a
name, b, and associates that
name with the integer, 3.

English: 
And in fact, it's helpful
if you understand.
So Python associates names and
entities in a very simple,
straightforward fashion.
And if you know the ground
rules, it makes it very easy
to deal with.
And if you don't know the ground
rules, it makes it very
hard to deal with.
So what's the ground rules?
Here's the gory details.
So Python associates names with
values in what Python
calls a binding environment.
An environment is just a
list that associates
a name and an entity.
So if you were to type b
equals 3 what Python is
actually doing is it's building
this environment.
When you type b equals 3, it
adds to the environment a
name, b, and associates that
name with the integer, 3.

Arabic: 
When you type x equals 2.2, it
adds a name, x, and associates
it with the float, 2.2.
When you say foo is minus 506
times 2, it makes the name,
foo, and associates it with
an int, minus 1012.
Then, if you ask Python about
b, the rule is look it up in
the environment and type the
thing that b refers to.
So when you type "b," what
Python really does is it goes
to the environment.
It says, do I have some entity
called "b?" Well, yes I do.
It happens to be an int, 3.
So it prints 3.
 
If you ask, what is "a?"
Python says, OK, in my
environment, do I have some
name, "a?" It doesn't find it.
So it prints out this cryptic
message that basically says,

English: 
When you type x equals 2.2, it
adds a name, x, and associates
it with the float, 2.2.
When you say foo is minus 506
times 2, it makes the name,
foo, and associates it with
an int, minus 1012.
Then, if you ask Python about
b, the rule is look it up in
the environment and type the
thing that b refers to.
So when you type "b," what
Python really does is it goes
to the environment.
It says, do I have some entity
called "b?" Well, yes I do.
It happens to be an int, 3.
So it prints 3.
If you ask, what is "a?"
Python says, OK, in my
environment, do I have some
name, "a?" It doesn't find it.
So it prints out this cryptic
message that basically says,

Arabic: 
sorry, guys, I can't find
something called "a" in the
current environment.
That's the key to the way Python
does all name bindings.
So in general, there's
a global environment.
You start typing to Python.
It just starts adding and
modifying the bindings in the
binding environment.
So if you type a equals 3 and
then type "a," it'll find 3.
If you then type "b=a+2," it
evaluates the right-hand side
relative to the current
environment.
So it first looks here.
And it says, do I have something
called "a?" Ah, yes.
It's an integer, 3.
Substitute that.
Do I know what 2 is?
Oh yeah, that's just an int.
Do I know what plus is?
Oh yeah, that's the thing
that combines two ints.
So it decides that a plus 2--

English: 
sorry, guys, I can't find
something called "a" in the
current environment.
That's the key to the way Python
does all name bindings.
So in general, there's
a global environment.
You start typing to Python.
It just starts adding and
modifying the bindings in the
binding environment.
So if you type a equals 3 and
then type "a," it'll find 3.
If you then type "b=a+2," it
evaluates the right-hand side
relative to the current
environment.
So it first looks here.
And it says, do I have something
called "a?" Ah, yes.
It's an integer, 3.
Substitute that.
Do I know what 2 is?
Oh yeah, that's just an int.
Do I know what plus is?
Oh yeah, that's the thing
that combines two ints.
So it decides that a plus 2--

English: 
it evaluates a plus 2 in the
current environment.
It gets 5.
And it says, oh, I'm trying
to do a new equals, a new
association, a new variable.
Make the name, b, points to this
evaluated in the current
environment.
So b gets associated
with int 5.
Then, if I do this line, it
evaluates b plus 1 in the
current environment.
b is 5 in the current
environment.
It adds 1.
It gets 6.
And then, it says, associate
this thing, 6, with b.
So it overwrites the b, which
had been bound to 5, and b is
now bound to 6.
OK?
So the whole thing, the way it
treats variables, the way
Python associates a name with
a value in a variable, is
evaluate the right-hand side
according to the current

Arabic: 
it evaluates a plus 2 in the
current environment.
It gets 5.
And it says, oh, I'm trying
to do a new equals, a new
association, a new variable.
Make the name, b, points to this
evaluated in the current
environment.
So b gets associated
with int 5.
 
Then, if I do this line, it
evaluates b plus 1 in the
current environment.
 
b is 5 in the current
environment.
It adds 1.
It gets 6.
And then, it says, associate
this thing, 6, with b.
So it overwrites the b, which
had been bound to 5, and b is
now bound to 6.
حسنا؟
So the whole thing, the way it
treats variables, the way
Python associates a name with
a value in a variable, is
evaluate the right-hand side
according to the current

English: 
environment.
Then, change the current
environment to
reflect the new binding.
What it does in the case of
sub-routines is very similar.
So here's an illustration of the
local environment that is
generated by this
piece of code.
When I say a equals 2, it
generates a name in the local
environment, a.
It evaluates the right-hand
side and finds 2.
So it makes a binding in the
local environment where the
name, a, is associated
with the integer, 2.
Then, I say define square of
x to be return x squared.
That's more complicated.
Python says, oh, I'm defining
a new operation.
It's a procedure.

Arabic: 
environment.
Then, change the current
environment to
reflect the new binding.
What it does in the case of
sub-routines is very similar.
 
So here's an illustration of the
local environment that is
generated by this
piece of code.
When I say a equals 2, it
generates a name in the local
environment, a.
It evaluates the right-hand
side and finds 2.
So it makes a binding in the
local environment where the
name, a, is associated
with the integer, 2.
Then, I say define square of
x to be return x squared.
 
That's more complicated.
Python says, oh, I'm defining
a new operation.
 
It's a procedure.

English: 
The procedure has a formal
argument, x.
It has a body, return
x times x.
I'm going to have to remember
all of that stuff.
So I'm trying to define a new
procedure called square.
It's going to make a
binding for square.
So in the future, if somebody
says the word square, it'll
find out, oh, square I
remember that one.
square, it's a procedure.
Just like the binding for a
variable might be an int, the
binding for a procedure is the
name of the procedure.
Then, in the procedure, which
is some other data structure
outside the environment, it's
got to remember the formal
parameters--
in this case, x--
and the body.
And for the purpose of
resolving what do the

Arabic: 
The procedure has a formal
argument, x.
It has a body, return
x times x.
I'm going to have to remember
all of that stuff.
 
So I'm trying to define a new
procedure called square.
It's going to make a
binding for square.
So in the future, if somebody
says the word square, it'll
find out, oh, square I
remember that one.
square, it's a procedure.
 
Just like the binding for a
variable might be an int, the
binding for a procedure is the
name of the procedure.
Then, in the procedure, which
is some other data structure
outside the environment, it's
got to remember the formal
parameters--
in this case, x--
and the body.
 
And for the purpose of
resolving what do the

Arabic: 
variables mean, it needs to
remember what was the binding
environment in which this
sub-routine was defined.
So that's this arrow.
So this sequence says, make a
new binding square, points to
a procedure.
The procedure has the
formal argument, x.
It has the body return
x times x.
And it has the binding.
It came from the environment,
E1, the current environment.
OK, is everybody clear?
So the idea is that the
environment associates names
with things.
The thing could be
a data item, or
it could be a procedure.
 
Then, when you call a procedure,
it makes a new
environment.
So what happens, then, when I
try to evaluate a form, square
of a plus 2?

English: 
variables mean, it needs to
remember what was the binding
environment in which this
sub-routine was defined.
So that's this arrow.
So this sequence says, make a
new binding square, points to
a procedure.
The procedure has the
formal argument, x.
It has the body return
x times x.
And it has the binding.
It came from the environment,
E1, the current environment.
OK, is everybody clear?
So the idea is that the
environment associates names
with things.
The thing could be
a data item, or
it could be a procedure.
Then, when you call a procedure,
it makes a new
environment.
So what happens, then, when I
try to evaluate a form, square
of a plus 2?

English: 
What Python does is it says,
OK, I need to figure
out what square is.
So it looks it up in the
environment, and it finds out
that square is a procedure.
Fine, I know how to deal
with procedures.
So then, it figures out this
procedure has a formal
argument, x.
Oh, OK, if I'm going to run this
procedure, I'm going to
have to know what x means.
So Python makes a new
environment--
here, it's labelled E2, separate
from the global
environment, E1.
It makes a new environment
that will
associate x with something.
Doesn't know what it is yet, it
just knows that this square
is a procedure that takes
a formal argument, x.
So Python makes a new
environment, E2, with x
pointing to something.
Then, Python evaluates the
argument a plus 2 in the
environment E1.
You called square of a plus 2
in the environment of E1.

Arabic: 
What Python does is it says,
OK, I need to figure
out what square is.
So it looks it up in the
environment, and it finds out
that square is a procedure.
Fine, I know how to deal
with procedures.
So then, it figures out this
procedure has a formal
argument, x.
Oh, OK, if I'm going to run this
procedure, I'm going to
have to know what x means.
So Python makes a new
environment--
here, it's labelled E2, separate
from the global
environment, E1.
It makes a new environment
ذلك سوف
associate x with something.
Doesn't know what it is yet, it
just knows that this square
is a procedure that takes
a formal argument, x.
So Python makes a new
environment, E2, with x
pointing to something.
Then, Python evaluates the
argument a plus 2 in the
environment E1.
 
You called square of a plus 2
in the environment of E1.

English: 
So it figures out what did
you mean by a plus 3.
Well, you were in the
environment E1.
So it means whatever a plus 3
would have meant if he had
just typed a plus 3 in
that environment.
So you evaluate a plus
3 in the environment
E1, and you get 5.
So then, this new environment,
E2, that is set up for this
procedure, square, associates
5 with x.
Now it's ready to
run the body.
So now, it runs this procedure,
return x times x.
But now, what it's trying to
resolve its variables, it
looks it up in E2.
So it says, I want to do
the procedure, the
body, x times x.
I need to know what x is, and
I need to know it twice.

Arabic: 
So it figures out what did
you mean by a plus 3.
Well, you were in the
environment E1.
So it means whatever a plus 3
would have meant if he had
just typed a plus 3 in
that environment.
So you evaluate a plus
3 in the environment
E1, and you get 5.
 
So then, this new environment,
E2, that is set up for this
procedure, square, associates
5 with x.
 
Now it's ready to
run the body.
So now, it runs this procedure,
return x times x.
But now, what it's trying to
resolve its variables, it
looks it up in E2.
So it says, I want to do
the procedure, the
body, x times x.
I need to know what x is, and
I need to know it twice.

Arabic: 
Look up what x means, but I
will look it up in my E2
environment that was built
specifically for this procedure.
And fortunately, there's
an x there.
So it finds out that x is 5.
It multiplies 5 times 5.
It gets the answer is 25.
It returns 25.
And then, it destroys this
environment, E2, because it
was only necessary for the time
when it was running the
procedure body.
هل هذا واضح؟
 
OK, so a slightly more difficult
example illustrates
what happens whenever everything
is not defined in
the current local environment.
What if I type define
biz of a?
Well, I create a new name in
the local environment that
points to a procedure.
The procedure has a formal
parameter, a, and a body that
returns a plus b.

English: 
Look up what x means, but I
will look it up in my E2
environment that was built
specifically for this procedure.
And fortunately, there's
an x there.
So it finds out that x is 5.
It multiplies 5 times 5.
It gets the answer is 25.
It returns 25.
And then, it destroys this
environment, E2, because it
was only necessary for the time
when it was running the
procedure body.
Is that clear?
OK, so a slightly more difficult
example illustrates
what happens whenever everything
is not defined in
the current local environment.
What if I type define
biz of a?
Well, I create a new name in
the local environment that
points to a procedure.
The procedure has a formal
parameter, a, and a body that
returns a plus b.

Arabic: 
The procedure also was defined
within the environment E1,
which I'll keep track of.
 
Then, if I say b equals 6, that
makes a new binding in
the global environment,
b equals 6.
Then, if I try to run biz
of 2, look up biz.
Oh, that's a procedure,
formal parameter, a.
Make an environment,
has an a in it.
What should I put in a?
Evaluate the argument, 2.
OK, a is 2.
Put two here.
Now, I'm ready to
run the body.
Run the body in the
environment, E2.
When I run return a plus
b in E2, I have to
first figure out a.
Well, that's easy. a is 2.
Then, I have to figure out b.
What's b?
 
AUDIENCE: 6?
PROFESSOR: 6.

English: 
The procedure also was defined
within the environment E1,
which I'll keep track of.
Then, if I say b equals 6, that
makes a new binding in
the global environment,
b equals 6.
Then, if I try to run biz
of 2, look up biz.
Oh, that's a procedure,
formal parameter, a.
Make an environment,
has an a in it.
What should I put in a?
Evaluate the argument, 2.
OK, a is 2.
Put two here.
Now, I'm ready to
run the body.
Run the body in the
environment, E2.
When I run return a plus
b in E2, I have to
first figure out a.
Well, that's easy. a is 2.
Then, I have to figure out b.
What's b?
AUDIENCE: 6?
PROFESSOR: 6.

Arabic: 
So how did you get 6?
AUDIENCE: [INAUDIBLE].
PROFESSOR: So this local
environment that was created
for the formal parameter has,
as its parent, E1 because
that's where the procedure
was defined.
 
So it doesn't find b in this
local environment.
So it goes to the parent.
Do you have a "b?" And it could,
in principal, propagate
up a chain of environments.
So you could construct
this hierarchically.
So it will resolve bindings in
the most recent environment
that has that binding.
So the answer, then, is that
when you run biz of 2, this b
gets associated with
that b, OK?
So that's how the environments
work for simple procedures and
simple data structures.

English: 
So how did you get 6?
AUDIENCE: [INAUDIBLE].
PROFESSOR: So this local
environment that was created
for the formal parameter has,
as its parent, E1 because
that's where the procedure
was defined.
So it doesn't find b in this
local environment.
So it goes to the parent.
Do you have a "b?" And it could,
in principal, propagate
up a chain of environments.
So you could construct
this hierarchically.
So it will resolve bindings in
the most recent environment
that has that binding.
So the answer, then, is that
when you run biz of 2, this b
gets associated with
that b, OK?
So that's how the environments
work for simple procedures and
simple data structures.

Arabic: 
It's very similar for the way
it works with classes.
So imagine that I had this
data, and I wanted to
represent that in Python.
What I might do is look at
the common features.
The courses are all the same.
The rooms are all the same.
The buildings are
all the same.
The ages are highly variable.
So I might want to create
a class that
has the common data.
So I might do this--
class Staff601.
The course is 601.
The building's 34.
The room is this.
The way Python implements a
class is as an environment.
Executing this set of statements
builds the class
environment.
هذه هي.
It's a list of bindings.
Here, I'm binding the
name, course, to the
string, 601, et cetera.
If there were a method, I
would do the same thing,
except it would look like
a procedure then.

English: 
It's very similar for the way
it works with classes.
So imagine that I had this
data, and I wanted to
represent that in Python.
What I might do is look at
the common features.
The courses are all the same.
The rooms are all the same.
The buildings are
all the same.
The ages are highly variable.
So I might want to create
a class that
has the common data.
So I might do this--
class Staff601.
The course is 601.
The building's 34.
The room is this.
The way Python implements a
class is as an environment.
Executing this set of statements
builds the class
environment.
This is it.
It's a list of bindings.
Here, I'm binding the
name, course, to the
string, 601, et cetera.
If there were a method, I
would do the same thing,
except it would look like
a procedure then.

Arabic: 
So this creates the Staff601
environment.
Staff601, because I executed
this class statement, that
creates a binding in the local
environment, Staff601, which
points to the new environment.
So now, in the future, when
Python encounters the name
Staff601, it will discover that
that's an environment.
Python implements classes
as environments.
So now, when I want to access
elements within a class, I use
a special notation.
It's a dot notation.
Python regards dots as ways of
navigating an environment.

English: 
So this creates the Staff601
environment.
Staff601, because I executed
this class statement, that
creates a binding in the local
environment, Staff601, which
points to the new environment.
So now, in the future, when
Python encounters the name
Staff601, it will discover that
that's an environment.
Python implements classes
as environments.
So now, when I want to access
elements within a class, I use
a special notation.
It's a dot notation.
Python regards dots as ways of
navigating an environment.

Arabic: 
When Python parses staff.room,
it looks up Staff601 in the
current environment.
If it finds an environment, it
then says, oh, I know about
this .room thing.
All I do is I look up
the room name in
the environment Staff601.
And when it does that, it
gets the answer 501.
And the same sort of
thing happens here.
It looks up Staff601.
It finds an environment.
It looks up coolness.
It finds out there
is no such thing.
Well, no, that's not true.
So it creates coolness within
601 and assigns an
integer, 11, to it.
So then, the way Python treats
methods is completely
analogous--
oh, excuse me, instances.
I'm doing instances first.

English: 
When Python parses staff.room,
it looks up Staff601 in the
current environment.
If it finds an environment, it
then says, oh, I know about
this .room thing.
All I do is I look up
the room name in
the environment Staff601.
And when it does that, it
gets the answer 501.
And the same sort of
thing happens here.
It looks up Staff601.
It finds an environment.
It looks up coolness.
It finds out there
is no such thing.
Well, no, that's not true.
So it creates coolness within
601 and assigns an
integer, 11, to it.
So then, the way Python treats
methods is completely
analogous--
oh, excuse me, instances.
I'm doing instances first.

Arabic: 
If I make pat be an instance
of Staff601, pat is an
instance of the class
Staff601.
pat is implemented as
an environment.
So when I make pat, pat points
to a new environment--
here, E3.
The parent of E3 is the class
that pat belongs to,
which is, here, E2.
 
And when I make the instance,
it's empty.
But now, if I ask what is
pat.course, well, pat points
to this environment.
Does this environment have
something called a course?
لا.
Does the parent?
نعم فعلا.
 
Course is bound to
the string 601.
So pat.course is 601
just the same as
Staff601.course had been 601.
pat is an instance.

English: 
If I make pat be an instance
of Staff601, pat is an
instance of the class
Staff601.
pat is implemented as
an environment.
So when I make pat, pat points
to a new environment--
here, E3.
The parent of E3 is the class
that pat belongs to,
which is, here, E2.
And when I make the instance,
it's empty.
But now, if I ask what is
pat.course, well, pat points
to this environment.
Does this environment have
something called a course?
No.
Does the parent?
Yes.
Course is bound to
the string 601.
So pat.course is 601
just the same as
Staff601.course had been 601.
pat is an instance.

English: 
It's a new environment
with the class
environment as its parent.
You can add attributes
to instances.
And all that does is populate
the environment associated
with the instance.
You can add methods
to classes.
And that does the same thing.
So here, I've got the class,
Staff601, which has a method,
salutation, instance
variables, course,
building, and room.
So when I build that structure,
Staff601 points to
an environment that contains
salutation, which is a
procedure, in addition to a
bunch of instance variables.
So now, all of the rules that
we've talked about with regard

Arabic: 
It's a new environment
with the class
environment as its parent.
 
You can add attributes
to instances.
And all that does is populate
the environment associated
with the instance.
You can add methods
to classes.
And that does the same thing.
So here, I've got the class,
Staff601, which has a method,
salutation, instance
variables, course,
building, and room.
So when I build that structure,
Staff601 points to
an environment that contains
salutation, which is a
procedure, in addition to a
bunch of instance variables.
 
So now, all of the rules that
we've talked about with regard

Arabic: 
to environments apply
now to this class.
So in particular, I can say
Staff601 salutation of pat.
When Python parses Staff601,
it finds an environment.
 
It says dot salutation.
Oh, I know how to do that.
Within the environment,
Staff601, look for a binding
for the name salutation.
Do I find one?
Well, yeah, there it is.
It points to a procedure.
So staff dot salutation
is a procedure.
Do just the same things that
we would have done with a
simple procedure.
The only difference
here is that the
procedure came from a class.
 
In this particular case, the
sub-routine that I define has
a formal parameter, self.

English: 
to environments apply
now to this class.
So in particular, I can say
Staff601 salutation of pat.
When Python parses Staff601,
it finds an environment.
It says dot salutation.
Oh, I know how to do that.
Within the environment,
Staff601, look for a binding
for the name salutation.
Do I find one?
Well, yeah, there it is.
It points to a procedure.
So staff dot salutation
is a procedure.
Do just the same things that
we would have done with a
simple procedure.
The only difference
here is that the
procedure came from a class.
In this particular case, the
sub-routine that I define has
a formal parameter, self.

Arabic: 
So then, that's going to have
to build when I try to
evaluate it.
That has to build a binding for
self, which is set to pat.
pat was an environment.
So self gets pointed to pat.
So now, when I run
Staff601.salutation on pat, it
behaves as though that generic
method was applied to the
instance pat.
 
We'll do that a lot.
It's a little bit
of redundancy.
We know that pat is a
member of Staff601.
So we will define a special
form-- or I should say, Python
defines a special form-- that
makes that easy to say.
This is the way we will usually
say, the instance pat
should run the class method
salutation on itself.

English: 
So then, that's going to have
to build when I try to
evaluate it.
That has to build a binding for
self, which is set to pat.
pat was an environment.
So self gets pointed to pat.
So now, when I run
Staff601.salutation on pat, it
behaves as though that generic
method was applied to the
instance pat.
We'll do that a lot.
It's a little bit
of redundancy.
We know that pat is a
member of Staff601.
So we will define a special
form-- or I should say, Python
defines a special form-- that
makes that easy to say.
This is the way we will usually
say, the instance pat
should run the class method
salutation on itself.

Arabic: 
This is simply a simplified
notation that means
precisely that, OK?
So what we covered today, then,
was supposed to be the
most elementary ideas in how
you construct modular
programs, Modularity
at the small scale.
How do you make operations that
are hierarchical, data
structures, and classes?
What we will do for the rest of
the week is practice those
أنشطة.
 

English: 
This is simply a simplified
notation that means
precisely that, OK?
So what we covered today, then,
was supposed to be the
most elementary ideas in how
you construct modular
programs, Modularity
at the small scale.
How do you make operations that
are hierarchical, data
structures, and classes?
What we will do for the rest of
the week is practice those
activities.
