Introduction to Programming and Computer Science - Full Course
freeCodeCamp.org
0:01 مرحبًا بك في مقدمة البرمجة. لي الاسم ستيفن
0:04 واسمي شون.
0:06 خلال 90 دقيقة القادمة ، سنأخذ لكم من خلال هذه السلسلة التي تتكون من 21 مختلفة
0:09 شرائح تأمل في تغطية أساسيات برمجة الكمبيوتر ، والتي يمكن تطبيقها على أي
0:13 وجميع لغات البرمجة التي قد تريدها ليتعلم. سنبدأ بالأبسط
0:17 سؤال ما هو البرمجة ، ومن سيكون هناك طريقنا إلى الأعلى بينما نتحدث
0:21 حول الميزات الشائعة لعلوم الكمبيوتر مثل الحلقات والمصفوفات. سنناقش
0:26 كيفية قراءة التعليمات البرمجية وكتابتها ، تصحيح التعليمات البرمجية التي قمت بها مكتوبة ، بعض الاستراتيجيات للمساعدة في التخطيط
0:30 الكود الخاص بك ، وأكثر من ذلك بكثير. الكامل قائمة المواضيع التي سيتم تغطيتها
0:35 في هذا الفيديو على غرار المحاضرة معروضة على الشاشة الآن. بالإضافة إلى ذلك ، سيكون هناك طوابع زمنية
0:39 في الوصف ، لذلك لا تتردد في التخطي إذا كنت بالفعل بارعًا في بعض المجالات
0:43 علوم الكمبيوتر ، أو تريد فقط أن تعرف حول موضوع معين سنتناوله.
0:47 نأمل ، بنهاية السلسلة ، سوف لديهم فهم أساسي لما الكمبيوتر
0:51 العلم ، جنبا إلى جنب مع مستودع للأسلحة مفيد المهارات التي ستساعدك على الكشف عن أيهما
0:55 لغة البرمجة التي تقرر تعلمها أولاً.
0:58 سنقوم فقط بتغطية النقاط الرئيسية الرئيسية التي تنطبق على جميع لغات البرمجة ، لذلك
1:02 سنبتعد عن مواضيع مثل التشفير الكينوني والملاحة بسطر الأوامر ،
1:07 لأن هذه أشياء خاصة بلغة معينة. بالإضافة إلى ذلك ، لن تكون هناك برامج مطلوبة
1:11 لتنزيلها من أجل المتابعة مع هذا البرنامج التعليمي لأننا لن نكتب
1:15 أي كود لإبقاء الأمور بسيطة ومركزة. هذا الفيديو مخصص للمهتمين
1:21 في علوم الكمبيوتر والبرمجة ولكن لديهم لا فكرة من أين تبدأ والقليل
1:25 لا توجد معلومات أساسية عن الترميز ، وهكذا إذا كان هذا يبدو لك ، ثم ربط شون و
1:29 أعمل في طريقنا من خلال عالم أحمق علوم الكمبيوتر ، بدءًا من الأكبر
1:33 السؤال ربما في عقلك ، وهو ما حتى البرمجة؟
1:37 حسنًا ، يعرفه القاموس على أنه العملية إعداد برنامج تعليمي لـ
1:43 جهاز ، ولكن هذا مربك حقًا تعريف ، لذلك من حيث ليمان ما بالضبط
1:50 هل هذا يعني؟ في الأساس ، إنها تحاول للحصول على جهاز كمبيوتر لإكمال مهمة معينة
1:55 دون ارتكاب أخطاء.
1:57 تخيل هذا ، على سبيل المثال: أنت تريد أقل ذكاءً منك صديق لبناء مجموعة ليغو ، إلا أنه لديه
2:05 فقدت التعليمات ويمكن بناء على أساس فقط على أمرك. تذكر رغم ذلك ، صديقك
2:11 هو أبعد ما يكون عن الكفاءة ، وهكذا إذا كانوا كذلك لم تعط تعليمات محددة للغاية حول كيفية
2:16 لبناء المجموعة ، هناك العديد من الأخطاء يمكنه أن يصنع. إذا كان يعتقد أنه جهاز كمبيوتر ،
2:22 ثم إذا كان لديك قطعة واحدة لم تخبره بالتحديد بمكان ومكان
2:25 كيفية وضعه ، فإن مجموعة ليغو بأكملها سوف يدمر وسيترك ليعاني
2:29 الانهيار العقلي الكامل يسبب الكل هدف المشروع بإفساد. إعطاء
2:35 تعليمات لصديقك مشابهة جدا إلى كيفية كود المبرمجين. بدلا من الأقل ذكاء
2:41 صديق ، لديك جهاز كمبيوتر أقل من الذكاء ، وبدلاً من الإرشادات حول كيفية البناء
2:46 مجموعة ليغو ، نحن نطعمها المعلومات حول كيفية إكمال برنامج مثل لعبة أو
2:50 تطبيق ويب. شيء مهم يجب ملاحظته هو أن أجهزة الكمبيوتر في الواقع غبية للغاية.
2:56 نحن نبنيها لتكون معقدة للغاية قطعة من التكنولوجيا ، عندما تكون في الواقع ، أ
3:01 الوظائف الرئيسية للكمبيوتر تأتي من كيف نتلاعب بها لخدمة احتياجاتنا.
3:05 الآن ، البرمجة ليست بسيطة مثل العطاء تعليمات صديقك منذ ذلك الحين في المبرمجين
3:10 الحالة ، الكمبيوتر لا يتكلم نفس لغة كما أنت ، يفهم الكمبيوتر فقط
3:14 رمز الآلة ، وهي لغة رقمية المعروف باسم ثنائي الذي تم تصميمه بحيث
3:19 يمكن للكمبيوتر قراءتها وتنفيذها بسرعة تعليماتها. تغذية كل تعليمات ل
3:24 يتم تحويل الكمبيوتر إلى سلسلة 1 و 0 ثم يتم تفسيرها بواسطة
3:29 الكمبيوتر لتنفيذ مهمة.
3:32 بالعودة إلى مثال ليغو ، هذه العملية سيكون لو لم يكن أقل ذكاء فقط ،
3:36 ولكن لجعل الأمور أسوأ ، لم يستطع أن يفهم اللغة الإنجليزية ويتحدث فقط في الماندرين الصينية.
3:43 من أجل التحدث معه ، عليك أن تتحول التعليمات التي تفهمها باللغة الإنجليزية
3:48 إلى اللغة التي يفهمها صديقك. هذه العملية هي في الأساس ما يجب عليك
3:53 القيام به لجهاز الكمبيوتر الخاص بك لجعله يفهم التعليمات التي تعطيها له.
3:57 الفرق الكبير بين المثالين ، ومع ذلك ، هو أنه من الصعب للغاية
4:02 الناس لفهم رمز الجهاز والثنائي. ترجمة ما تريد الكمبيوتر مباشرة
4:06 القيام به في كود الآلة أمر صعب للغاية ، في الواقع يكاد يكون من المستحيل ، وسوف يستغرق
4:12 وقت طويل للقيام به إذا استطعت. كل يتكون البرنامج من ملايين وملايين
4:17 من تلك الأرقام 1 و 0 ، فكيف بالضبط ، هل من المفترض أن نترجم تعليماتنا؟
4:22 إلى رمز الجهاز؟
4:25 هذا هو المكان الذي تأتي فيه لغات البرمجة لعب. لغات البرمجة هي في الأساس
4:29 رجل وسط لترجمة برنامج إلى كود الآلة. هذه اللغات أسهل بكثير
4:34 للبشر ليتعلموا من كود الآلة وبالتالي مفيدة للغاية للمبرمجين. ذاهب
4:39 بالعودة إلى مثال ليغو ، لغة البرمجة سيكون نوعًا ما مثل مترجم ، هذا
4:44 قادرة على أخذ التعليمات التي تعطيها لهم باللغة الإنجليزية ، وترجمتها إلى تعليمات
4:48 يمكن أن يفهم صديقك غير الناطق باللغة الإنجليزية. هذا يجعل لغات البرمجة للغاية
4:53 مفيدة والعمود الفقري لأي سلعة تقريبا برنامج. فكر بلغات البرمجة على أنها
4:58 ليس الإنجليزية ، وليس رمز الجهاز ، ولكن في مكان ما في المنتصف.
5:03 هناك العديد من لغات البرمجة المختلفة هناك أن لكل منها فريد خاص بها
5:07 الاستخدامات. تعمل لغات مثل Python و Java كلغات الأغراض العامة التي يمكن أن تؤدي
5:12 مجموعة متنوعة من المهام الحسابية ، بينما RobotC أو HTML / CSS هي لغات مصممة للمزيد
5:18 أغراض محددة مثل تحريك الروبوت أو بناء موقع على شبكة الإنترنت. يمكن للغات أيضا
5:24 تختلف في مدى قوتها. على سبيل المثال، JavaScript هي لغة برمجة نصية
5:29 مصمم للمهام الأصغر أثناء استخدام جافا أو الثعبان يمكن أن تنفذ المزيد من الضرائب الحسابية
5:34 العمليات.
5:35 نقيس قوة لغة البرمجة ، أو المستوى ، من خلال مدى تشابهه مع الجهاز
5:41 كود ، سلسلة من 0 و 1 تحدثنا في وقت سابق. لغات برمجة منخفضة المستوى
5:46 مثل التجميع أو C أقرب إلى الثنائية من لغة برمجة عالية المستوى مثل
5:51 مثل Java أو python.
5:53 الفكرة الأساسية هي أنه كلما انخفض المستوى من لغة البرمجة الخاصة بك ، أكثر الخاص بك
5:58 سيشبه الرمز ما يمكن للآلة تفسيره كإرشادات. بصرف النظر عن الاختلاف
6:03 الأغراض التي تفي بها كل لغة ، والاختيار عادة ما تنخفض لغة البرمجة
6:07 إلى مسألة تفضيل ، كما هو الحال عادة العديد من اللغات التي تؤدي مهام مماثلة.
6:13 جرب لغات مختلفة ، وحدد أيها القواعد والواجهة ومستوى التبسيط
6:17 هل تريد أفضل.
6:20 والآن بعد أن عرفنا ما هي البرمجة ، كيف هل نكتب رمز بالفعل؟ ليست ك
6:26 يمكننا ببساطة كتابة الكلمات في مستند نصي ونفترض أن الكمبيوتر
6:30 يمكن ترجمتها إلى كود الآلة ، قراءتها ، وتنفيذ مهمة مثل فتح متصفح.
6:35 بالإضافة إلى ذلك ، لا يمكننا الكتابة فقط القمامة في بعض لغات البرمجة المذكورة
6:39 في الحلقة السابقة ونتوقع الكمبيوتر لفهم. فكيف يفترض بنا أن نكتب
6:43 رمز بعد ذلك؟
6:44 حسنا ، الجواب مع IDE. وهو IDE الذي لتقف على بيئة التنمية المتكاملة ،
6:49 يسمح بتسهيل التعليمات البرمجية بواسطة الكمبيوتر. توفر IDE واجهة رسومية على جهازك
6:54 كمبيوتر يمكن للمبرمج بسهولة الكتابة والتشغيل وتصحيح التعليمات البرمجية دون الحاجة
6:58 للقلق بشأن مشاكل التجميع أو تفسير البرنامج. فكر في
7:03 IDE مثل أي برنامج آخر على جهاز الكمبيوتر الخاص بك مثل لعبة أو متصفح أو حتى الملف
7:07 المستكشف ، إلا أننا سنستخدمه للكتابة الشفرة. IDE قادرون على تحويل التعليمات البرمجية الخاصة بك إلى
7:11 رمز الجهاز وتشغيله من خلال الكمبيوتر لتحقيق نتائج.
7:15 بالإضافة إلى توفير مكان للمبرمجين لتطوير الكود الخاص بهم ، توفر IDE بعضًا
7:19 أدوات مفيدة للغاية للمبرمجين تسهيل مهمة كتابة التعليمات البرمجية ، مثل المضمنة
7:23 التحقق من الخطأ لأنه كما سنتحدث عنه في وقت لاحق؛ لا يعمل الرمز دائمًا بشكل صحيح ،
7:27 ملء تلقائي للكلمات أو الكلمات المستخدمة بشكل متكرر العبارات ، والتسلسل الهرمي للمشروع الذي سوف
7:31 مساعدتك في تنظيم الملفات ومعالجتها ضمن مشروعك. مرة أخرى في الأيام الخوالي ،
7:36 قبل IDE ، كان الرمز مكتوبًا عليه لكمة البطاقات ثم تغذيها في أجهزة الكمبيوتر التي
7:40 سيستغرق ساعات ويسبب الكثير من الألم. تعمل IDE في الوقت الحاضر كنوع من المسار السريع
7:45 لكتابة التعليمات البرمجية وجعل الأشياء كثيرة أسهل للمبرمجين. مثال محدد
7:50 يمكن رؤية IDE على شاشتك الآن. في ال مركز يمكنك رؤية البرنامج الحالي
7:54 يتم كتابتها ، وأسفلها مباشرة وحدة التحكم ، التي يمكن أن تطبع معلومات مفيدة ل
7:58 المبرمج. يتم استخدام IDE المحدد هذا لكتابة كود جافا. IDE هي للغاية
8:04 قوية وسوف تستخدم في ما يقرب من 100 ٪ من مشاريع البرمجة الخاصة بك.
8:08 حتى من خلال هذه IDE نحن قادرون أخيرا لكتابة وتجميع التعليمات البرمجية بسلاسة بدون
8:12 القلق بشأن عدم قدرة الكمبيوتر لفهمها. المشكلة التالية التي نديرها
8:16 في ثم يصبح كيف نكتب هذا الرمز في IDE ، لأنه ليس كما يمكننا
8:21 فقط اكتب كلمات عشوائية من برمجة معينة اللغة ونتوقع أن يفهم المترجم
8:25 عليه. هذا هو مكان لغة البرمجة يأتي بناء الجملة في اللعب.
8:29 الآن ، كما لو كنت تتعلم لغة حقيقية ، يمكن أن يكون تعلم لغة الكمبيوتر متشابهًا جدًا.
8:35 بعضها لديه أنماط مختلفة قد تبدو غريبة ، قد يجعلك البعض تستخدم مفاهيم مجردة أو غريبة
8:40 التي قد تكون مربكة ، ومثل جميع اللغات ، لغات البرمجة لديها مجموعة من القواعد
8:44 التي يجب عليك اتباعها عند كتابة الرمز تلك اللغة ، وفي طليعة تلك
8:48 القواعد هي القواعد. تتم الإشارة إلى قواعد البرمجة إلى النحو وتشبه إلى حد كبير في العالم الحقيقي
8:54 قواعد. كل لغة برمجة لها بناء الجملة ، أو القواعد ، التي يجب عليك اتباعها
8:59 إلى نقطة الإنطلاق إذا كنت تريد أن يعمل برنامجك بشكل صحيح ، كما لو كنت تتحدث في الحياة الواقعية.
9:04 يمكن أن تكون هذه أشياء مثل كيف تكتب وظائف معينة ، ما تضعه في النهاية
9:08 سطر التعليمات البرمجية وكيفية إعداد معينة المهام. كل لغة فريدة من نوعها
9:13 النحو ، وبينما قد يشارك البعض قواعد مماثلة ، كل شيء سيكون له بعض الغرابة مما يجعله يقف
9:18 للخروج من البقية. بناء الجملة شيء يمسك الكثير من الناس على حين غرة ، منذ الكثير
9:22 توقع أن تتبعها كل لغة برمجة نفس مجموعة القواعد ، لكن كما تحدثنا
9:27 في الجزء الأخير ، لأن كل لغة متخصص لمهمة محددة ، كل احتياجات
9:31 مجموعة القواعد الخاصة بها للعمل. كسر أو تجاهل هذه القواعد سيؤدي إلى
9:36 خطأ ، فقط كيف كسر أو تجاهل القواعد في الحياة الحقيقية ستؤدي إلى غير مقصود
9:41 رسالة.
9:43 كمثال. إذا أردنا أن نفعل شيئًا بسيطة مثل تهيئة متغير ، والذي
9:47 شيء لم نقم بتغطيته بعد المثال لا يزال ذا صلة. في جافا ، سوف
9:51 لاحظ أننا يجب أن نحدد نوع المتغير نحن نحدد في هذه الحالة عدد صحيح و
9:56 أيضا إضافة فاصلة منقوطة بعد العبارة. في الثعبان ، لا نحتاج حتى للتعريف
10:00 أننا نحاول إنشاء متغير و فقط اكتب ما نريد أن ننشئه ،
10:05 وفي جافا سكريبت ، نحدد أننا فقط صنع متغير ، ولكن لا تتضمن ما
10:09 نوع المتغير الذي نريد إحداثه. حتى في هذا المثال البسيط يمكنك أن ترى مقدار النحو
10:15 مهم عند تعلم لغة جديدة منذ ذلك الحين بينما ظل هدف برنامجنا هو
10:19 نفس ، تعريف عدد صحيح بقيمة ثلاثة ، أخذت كل لغة البرمجة المعروضة مختلفة
10:25 اقتراب. كل هذه اللغات تتطلب ذلك أنت تتبع بناء الجملة هذا لأن تذكر أجهزة الكمبيوتر
10:30 غبية للغاية ، إذا نسيت فاصلة منقوطة واحدة أو يسيء حرف ، البرنامج بأكمله
10:35 لن يعمل ويعيد لك خطأ في بناء الجملة ، وهو أمر سنتحدث عنه لاحقًا.
10:40 فكر في ذلك كما لو نسيت فاصلة فيه جملة والسياق الكامل لما
10:43 تحاول القول يساء تفسيرها. على سبيل المثال ، في جملة "دعونا نأكل ،
10:49 جدتي ". إذا نسيت هذه الفاصلة ، بينما قد يبدو خطأ صغير ،
10:53 يغير سياق الجملة بالكامل ، يجعل الأمر يبدو وكأنك على وشك تناول الطعام
10:56 جدتك. تتبع نفس القواعد للبرمجة ، إذا نسيت فاصلة منقوطة ، السياق بأكمله
11:02 من برنامجك يمكن أن يكون تالفا أو يساء تفسيره.
11:06 الآن شيء آخر يجعل IDE مفيدًا جدًا هو أنهم سيعلموك إذا ومتى
11:10 هناك أخطاء في بناء الجملة في التعليمات البرمجية الخاصة بك. بناء الجملة أخطاء بالطبع كونها أجزاء من التعليمات البرمجية الخاصة بك
11:15 التي لا تتبع القواعد التي تحدثنا عنها سابقا. سوف يخبرك IDE أين
11:20 الكود الخاص بك هو الخطأ ، ولن تسمح أيضا تقوم بتشغيل البرنامج الخاص بك حتى كان الخطأ
11:24 ثابت. بسبب أهمية بناء الجملة لكتابة التعليمات البرمجية وتعلم لغة جديدة ،
11:29 من المستحسن أن تتعلم القواعد وبناء لغة قبل البداية
11:32 لكتابة برامج معقدة بهذه اللغة. معظم القواعد مملة للتعلم ولكن
11:37 من السهل إتقانها وبمجرد أن تفعل ذلك ، ستتمكن من تحديد بناء الجملة بسهولة
11:41 الأخطاء ورعايتهم بسهولة.
11:45 هذا يغطي جوهر بناء الجملة والبرمجة القواعد ، حتى الآن بعد أن عرفنا كيفية كتابة الرمز ،
11:49 وحيث نكتب الرمز ، نحتاج بعد ذلك إلى تغطيته ماذا يحدث بعد كتابة برنامجنا
11:53 وتشغيل التعليمات البرمجية الخاصة بنا. لأن كتابة قطعة كود لعبة أو قاعدة بيانات رائع
11:57 وكل شيء ، ولكن بعد تفسير الكمبيوتر البرنامج ، كيف سنعرف ما يحدث ،
12:01 وعما إذا كانت تعمل أم لا؟ حسنا ، المبرمجين قم بذلك من خلال النظر إلى وحدة التحكم. وحدة التحكم
12:06 هي واجهة نصية داخل الكمبيوتر يمكن للمبرمجين استخدام لنا لمجموعة متنوعة من مختلفة
12:10 المقاصد. إذا كنت تتذكر ، منذ فترة قصيرة عرضنا صورة IDE أساسية وواحدة
12:15 من الأجزاء الرئيسية لتلك الصورة كان وحدة التحكم.
12:18 الاستخدام الرئيسي لوحدة التحكم هو إخراج النص من البرنامج. يتم ذلك عادة باستخدام
12:23 بيان طباعة. بيان الطباعة هو الأمر الذي يفعل بالضبط ما يبدو عليه:
12:27 يطبع النص إلى وحدة التحكم. هذه الطباعة البيان هو أول قطعة من قانون ACTUAL
12:31 تحدثنا عنها في هذه السلسلة ، وهي كذلك حول البساطة التي تحصل عليها. بيان الطباعة ،
12:35 على الرغم من بساطتها ، هي واحدة من أكثر وظائف مهمة في البرمجة وتوجد
12:39 بشكل ما في كل برمجة تقريبًا لغة.
12:41 أبسط شيء يمكنك أن تطلبه من الطباعة البيان الذي يجب القيام به هو ببساطة جعله يقول
12:46 شيئا ما. يتم ذلك عن طريق إرشاد وحدة التحكم للطباعة ، ثم تضمين أي شيء
12:50 تريد طباعتها داخل الأقواس. على سبيل المثال ، في بايثون ، جزء من التعليمات البرمجية
12:55 طباعة ("Hello World") ستسبب رسالة قراءة "مرحبا العالم" لتظهر على
13:00 وحدة التحكم. أنيق جدا.
13:01 بيان الطباعة ضروري أيضًا للعرض وتفسير إخراج الكمبيوتر من
13:05 برنامج. على سبيل المثال ، إذا أخبرت الكمبيوتر لإجراء عملية حسابية بسيطة ، على سبيل المثال
13:11 لتحديد ما هو 4 + 3 ، سيتم تشغيله البرنامج داخليًا وحساب الإجابة.
13:16 ومع ذلك ، ما هو الغرض من الحصول على تشغيل الكمبيوتر هذا البرنامج إذا لم تقم بذلك
13:19 تكون قادرة على معرفة النتيجة؟ في حين أن مجرد إخبار الكمبيوتر بالأداء
13:22 هذا الحساب ، إرشاد الكمبيوتر إلى طباعة إخراج البرنامج إلى وحدة التحكم ،
13:26 وعند الانتهاء من البرنامج ، سوف 7 تظهر على وحدة التحكم. كما ترون ،
13:30 تسمح لنا وحدة التحكم بطباعة المعلومات بسهولة إلى المطور لمجموعة متنوعة من الاستخدامات.
13:34 من المهم ملاحظة أن بيان الطباعة يختلف باختلاف لغة البرمجة
13:37 تم استخدامها. على سبيل المثال ، في Java هناك إصدارات متعددة من بيان الطباعة حسب
13:42 على ما إذا كنت تريد فاصل أسطر بعد ذلك النص المطبوع وبيانات الطباعة المتخصصة
13:46 مما يجعل الشفرة الخاصة بك أكثر كفاءة. أيضا، بناء الجملة العام باستخدام عبارة طباعة
13:51 وبعض الفروق الدقيقة في وظيفتها يمكن أن تتغير بين اللغات. ومع ذلك ، يمكنك بشكل عام
13:55 الاعتماد عليه للقيام بنفس الوظيفة العامة ، كما هو بيان تأسيسي للبرمجة
14:00 بشكل عام. لذا اطبعوا البيانات ، طبعوا المعلومات إلى وحدة التحكم للمطور
14:02 للاستخدام ، لطيف.
14:03 كل وظائفها تجعل بيان الطباعة ، جنبا إلى جنب مع وحدة التحكم ، مطور مفيد للغاية
14:06 أداة. ومع ذلك ، من المهم أن نتذكر هذا كل ما في الأمر: أداة مطور.
14:11 وحدة التحكم ليست مخصصة حقًا للعرض بواسطة المستخدم النهائي لبرنامجك. أنه يميل
14:15 أن تكون مختبئة خلف الكواليس وغيرها طرق عرض المعلومات مثل
14:18 يتم استخدام عرض النص أو الرسومات أو الصور لنقل المعلومات إلى المستخدم بدلاً من ذلك.
14:23 فكر في الأمر على هذا النحو ، عندما تستخدمه هاتفك ، ترى وحدة التحكم في أي من
14:27 البرامج التي تستخدمها. لذلك بينما يمكنك استخدامها وحدة التحكم لتزويد نفسك بمعلومات حول
14:30 كيف يعمل برنامجك ، لا تحاول لتنفيذها في المنتج النهائي ل
14:34 بشكل أساسي لا يعني ذلك فقط. عموما ، تذكر استخدام وحدة التحكم الخاصة به
14:38 أقصى حد عند الكتابة وحل المشاكل في برامجك ، لأنها أداة رائعة
14:43 استخدمه لمعرفة أداء برنامجك خلف الكواليس.
14:48 الآن بعد أن عرفنا مجموعة كاملة من المعلومات حول لغات البرمجة وكيف وأين
14:52 لكتابتها ، مع بيان الطباعة تحت أحزمة لدينا ، دعونا نذهب إلى بعض بديهية
14:56 الأشياء التي يمكن للكمبيوتر القيام بها بمفرده ، دون أن تضطر إلى إخبارها كيف. أكثر
15:00 على وجه التحديد ، سنغطي العدد الأساسي الرياضيات وكذلك سلسلة الرياضيات
15:05 بدءا من الرياضيات الأساسية ، الكمبيوتر يعرف بالفعل كيفية إجراء عملية حسابية بسيطة.
15:10 وهذا يشمل الجمع والطرح والضرب والانقسام ، وكلها ممثلة
15:15 بالرموز الموضحة على الشاشة الآن. في أي IDE قد تقوم بتثبيته ، ستكون
15:19 قادرة على طباعة الإجابة على الرياضيات البسيطة مشاكل في استخدام بيان الطباعة ، والتي
15:23 قد يبدو غير بديهي لأنه لماذا تستخدم الكمبيوتر لإجراء الرياضيات عندما يكون لديك
15:26 آلة حاسبة جيدة تمامًا على هاتفك ، ولكن عليك أن تتذكر أن أجهزة الكمبيوتر
15:31 أي شيء نريده أن يفعله الكمبيوتر علينا أن نبني من الصفر. الحساب الأساسي ،
15:36 في حين أنه بسيط ، يساعد في أي برنامج تقريبًا يمكنك الكتابة. على سبيل المثال ، إذا أردنا ذلك
15:42 سنقوم بإنشاء تطبيق حاسبة أساسي ، سنحتاج إليه للاستفادة من هذه الوظيفة من أجل
15:46 عرض الإجابة على الحساب بشكل صحيح مشكلة عندما يحاول مستخدمنا الجمع والطرح
15:52 ضرب أو قسمة رقمين.
15:54 الآن بالإضافة إلى معادلات الرياضيات الأساسية الأربعة ، تتضمن معظم لغات البرمجة إضافية
15:59 عامل يعرف باسم معامل. إذا كان هذا هو الخاص بك أول مرة سمعت هذه الكلمة ، لا تقلق ،
16:04 لأنه لا يتم تدريسها عادة في فصول الرياضيات. المعامل يسمح لنا بالحصول على ما تبقى
16:08 عملية التقسيم. على سبيل المثال ، متى نأخذ 10 معامل 3 ، نقول بشكل أساسي
16:14 الكمبيوتر لأخذ 10 ، تقسيمه على 3 ، تجاهل الجواب الفعلي وتعطينا الباقي
16:19 من هذه العملية في هذه الحالة 1 ، منذ متى نقسم 10 على 3 ، والجواب 3 الباقي
16:25 1. الرقم 1 في هذه الحالة هو ما يتم طباعته إلى وحدة التحكم. إذا لم يكن هناك ما تبقى ،
16:32 نقول في حال أخذنا 50 معامل 2 ، بما أن الباقي يساوي 0 ، فستكون الوظيفة
16:37 قم بإرجاع 0 إذا كنا سنطبعها.
16:41 يمكن أن يكون هذا مفيدًا للغاية في كثير من الحالات ، الأكثر وضوحا إذا أردنا أن نحدد
16:45 سواء كان عدد صحيح معين أم لا غريب. إذا أخذنا معامل رقم معين 2
16:52 ويعود 0 ، ثم نعلم أنه حتى منذ ذلك الحين ينتج دائمًا أي رقم زوجي مقسوم على 2
16:57 في إجابة كاملة دون الباقي ، ولكن إذا أعاد النظام 1 ، فنحن نعرف ذلك
17:02 العدد الصحيح غريب. ستجد نفسك باستخدام عوامل الرياضيات الأساسية أكثر من ذلك بكثير
17:07 مما تعتقد ، لذلك من الجيد الاحتفاظ بها في الاعتبار عند كتابة برامجك.
17:11 الآن يمكن لجهاز الكمبيوتر لدينا العمل مع الأرقام ، مثل كذلك السلاسل. أوتار بالمناسبة شيء آخر
17:17 طريقة فقط لقول النص. على سبيل المثال ، "مرحبًا العالم "هو سلسلة ، والحرف" أ "هو
17:22 سلسلة ، أي شيء محاط بعلامات اقتباس يُشار إليه على أنه سلسلة في لغة البرمجة.
17:27 سنتناول المزيد عن السلاسل النصية بعد قليل عندما نتحدث عن المتغيرات ، ولكن في الوقت الحالي
17:32 فلنكمل. تحدثنا بالفعل عن طباعة السلاسل إلى وحدة التحكم ، ولكن دعونا
17:36 لنفترض أننا نصنع لعبة ، وأردنا ذلك طباعة البيان "
17:39 "انتهت اللعبة ، 4 كانت نتيجتك النهائية". الآن بينما يمكننا فقط أن نصنع سلسلة
17:44 يقول هذه العبارة بالضبط وطباعتها وحدة التحكم ، في بعض الحالات سيكون أكثر
17:48 من المفيد طباعة القيمة الصحيحة الفعلية ، خاصة في حالة وجود لعبة فيها
17:52 يمكن أن تتغير النتيجة في كل مرة تلعب ، لأن النتيجة بالتأكيد لن تكون دائمًا
17:57 4. حسنًا ، يمكننا أيضًا طباعة العديد سلاسل نصية ، وحتى أعداد صحيحة "بإضافة"
18:03 لهم معا في بيان الطباعة. هذه يسمى التسلسل.
18:08 الاستمرار في مثال درجاتنا. إذا أردنا لطباعة عبارة "انتهت اللعبة ، 4
18:12 كانت نتيجتك النهائية "، باستخدام 4 كعدد صحيح بدلاً من سلسلة ، يمكننا القيام بذلك عن طريق
18:17 تقسيم البيان إلى سلسلتين وعدد صحيح مثل ذلك.
18:21 اطبع ("انتهت اللعبة ،" + 4 + "كانت النتيجة النهائية)
18:27 نبدأ بالطبع ببيان مطبوع ، والتي ستختلف مرة أخرى عبر جميع اللغات.
18:34 داخل بيان الطباعة نبدأ بها طباعة السلسلة "انتهت اللعبة". الآن
18:39 هنا يأتي الجزء المهم ، من هناك ، نستخدم علامة الجمع وإضافة 4 إلى الطباعة
18:44 البيان ، كما لو كنت تضيف اثنين أعداد. ثم يمكننا تكرار هذه العملية
18:48 بعلامة + أخرى للسلسلة النهائية "كانت نتيجتك النهائية "ونحن قادرون على الطباعة
18:54 من جملة بياننا بسهولة. من خلال القيام بذلك ، يمكننا بسهولة طباعة عدة أوراق
18:59 سلاسل وأعداد صحيحة مختلفة في بيان مطبوع واحد.
19:03 يمكننا أيضًا الجمع بين الدروس التي لدينا تعلمت حتى الآن وتفعل شيئًا مثل "اللعبة
19:08 انتهى ، "+ (4 + 4) +" كانت نتيجتك النهائية "، في هذه الحالة لنقول أين لدينا لعبة
19:14 الذي يمنحك النتيجة الأساسية ، ثم 4 نقاط لمهمة معينة أكملتها. هذه المظاهرة
19:19 يعرض أيضًا جزءًا مهمًا آخر من البرمجة ، وهو في كثير من الأحيان للحصول على برنامجك
19:24 لتكون أكثر كفاءة ، يجب عليك الجمع جوانب التعليمات البرمجية.
19:28 الآن من المهم أن نلاحظ أن الكمبيوتر سيأخذ كل ما تضعه بين قوسين
19:32 وطبعها حرفًا للشخصية ، لذلك في كثير من الأحيان ينسى المبرمجون الإضافة
19:36 مسافة في نهاية أوتارهم. هذه يمكن أن يؤدي إلى خطأ صغير فيه
19:41 ستتم طباعة سلسلة من المثال السابق خارج كما لو أن أقول
19:44 "انتهت اللعبة ، كانت 4 نقاطك النهائية" التي ليس استرضاء عند عرضها على الشاشة
19:48 للمستخدم ، لذا من الأفضل دائمًا ضع مسافة بعد الأوتار وقبلها
19:53 للتأكد من أن هذا لا يحدث ، ولكم السلسلة لا تنتهي هكذا.
19:58 شيء آخر مهم يجب ملاحظته هو الفرق بين "4" بين علامتي اقتباس و 4 بدون
20:03 علامات الاقتباس. الآن "4" في الاقتباس يتم التعامل مع العلامات كسلسلة بدلاً من أ
20:09 4 بدون علامات اقتباس يتم معالجتها كرقم. قد لا يبدو هذا كبيرا
20:14 صفقة ، ولكن مرة أخرى أجهزة الكمبيوتر البكماء ، وإذا حاولت إجراء الرياضيات برقم في الاقتباس
20:19 علامات أنها ستعود خطأ ، لأن الكمبيوتر لا يفهم أنك
20:23 تحاول إجراء العملية على رقم ، وتعتقد أنك تحاول إضافة عدد صحيح
20:27 إلى سلسلة ، وهو رقم كبير في البرمجة. لذلك عندما تقوم بالبرمجة تأكد من القيام بذلك
20:33 ملاحظة عقلية حول ما إذا كنت تريد أم لا جعل شيء عدد صحيح ، أو سلسلة ، لأن
20:37 هذا النوع من الأشياء يحدث فرقًا كبيرًا. حسنا ، هذا يختتم الجزء على
20:42 القوة الأساسية لأجهزة الكمبيوتر.
20:45 الآن بعد ذلك سنقوم بتغطية واحدة من أهم مكونات الكمبيوتر
20:48 العلم ، لذلك تأكد من الانتباه لأن بعد ذلك سنقوم بتغطية المتغيرات ،
20:52 ما هي وكيف نستخدمها.
20:55 بادئ ذي بدء ، ما هو المتغير بالضبط؟ المتغير هو ببساطة شيء يمكن تخزينه
20:59 المعلومات ويمكن الرجوع إليها والتلاعب بها. فكر في المتغيرات مثل صندوق من الورق المقوى. ورق مقوى
21:05 مربعات بمثابة وسيلة لتخزين العناصر فيها والتي يمكن تغييرها واستبدالها وتعديلها.
21:10 المتغيرات مثل صناديق الكرتون التي يتم تخزينها معلومات للمبرمج كمرجع ،
21:14 التلاعب ، والإشارة إلى. كل متغير ببساطة لديه نوع واسم وقطعة من المعلومات
21:18 مخزنة داخله. نوع وقطعة سيتم تغطية المعلومات التالية والاسم
21:22 هو ببساطة اسم للمتغير ، فكر في على أنها كتابة ملصق على الورق المقوى
21:26 مربع في شربي.
21:27 الآن ، هناك العديد من أنواع المتغيرات المختلفة التي يمكن للمبرمج استخدامها ، ولكننا الآن
21:32 سيغطي فقط ما يسمى "بدائي المتغيرات "، والتي تشمل الأعداد الصحيحة ، المنطقية ،
21:36 يطفو ويضاعف ، وسلاسل ، وحروف.
21:40 سنبدأ الحديث عن عدد صحيح. العدد الصحيح ، أو int باختصار ، هو بهذه البساطة
21:46 كما يبدو: متغير يمكنه تخزين قيمة عدد صحيح. وهذا يشمل جميع الأعداد الصحيحة
21:51 من -2،147،483،648 إلى 2،147،483،648. الآن لاحظ كيف قلت الأعداد الصحيحة ، المتغيرات الصحيحة
22:04 لا يمكن ولن يحمل أي قيم عشرية ، لذلك ضع ذلك في الاعتبار عند استخدام المتغيرات.
22:09 ثانياً ، منطقي. منطقي جدا متغير بدائي يمكنه تخزين قيمة
22:13 صواب أو خطأ. المتغيرات المنطقية يمكن أن تحمل هاتين القيمتين فقط ، وهي غاية
22:19 مفيدة للبيانات الشرطية ، التي نحن سيغطي قريبا.
22:22 النوعان التاليان من المتغيرات هما عوامات ويتضاعف. كل من هذه الأنواع المتغيرة
22:26 هي أنواع بيانات النقطة العائمة ، والتي هي في الأساس يعني أن هذه المتغيرات يمكنها تخزين الأرقام
22:30 مع المنازل العشرية. في حين أن القيم الصحيحة لا يمكن أن تحتفظ بالقيم العشرية وتطفو وتضاعف
22:36 يستطيع. والفرق الرئيسي بينهما يمكن للمتغير العائم تخزين أعداد منه
22:40 دقة تصل إلى 32 بت ، بينما العلبة المزدوجة تخزين أرقام بدقة تصل إلى 64 بت.
22:45 بشكل أساسي ، يمكن أن يقوم الزوج بتخزين أكثر عشرية أماكن عوامة ، لذلك ينزل كل شيء
22:50 إلى أي مدى تريد أن يكون المتغير دقيقًا.
22:52 التالي لدينا متغيرات السلسلة ، وهي مثل الأوتار التي تحدثنا عنها بالفعل
22:55 مسبقا باستثناء تخزينها في مكان ما في قيمة. يمكن لمتغيرات السلسلة تخزين سلاسل الحروف ،
23:01 وهي مجرد كلمات وجمل. سلاسل مفيدة لعرض النص والتخزين
23:05 معلومات الإدخال. يمكن أيضًا ربط السلاسل معًا لتشكيل مجموعات من متغيرات السلسلة
23:09 وسلاسل مكتوبة مسبقًا. هذا مفيد جدا لإخراج المعلومات بتنسيق قابل للقراءة
23:14 للمستخدم. على سبيل المثال ، تخيل أننا تحتوي على سلسلة تسمى "name". الرمز
23:18 يطلب المدخلات ، ويخزن تلك السلسلة نص في الاسم. لإخراج هذه المعلومات ل
23:22 المستخدم ، بدلاً من مجرد عرض الاسم ، يمكنك إضافة عبارة "اسمك
23:25 هي: "واجعلها جملة بسلسلة "اسمك:" + اسم + "." هذه
23:31 يجعل من السهل قراءة التعليمات البرمجية الخاصة بك ، بينما مضيفا التباين إلى التعليمات البرمجية الخاصة بك ، والتي دائما
23:36 يجعل الأشياء أكثر إثارة للاهتمام للنهاية المستعمل.
23:38 أخيرًا ، لدينا متغيرات char. شار يقف للشخصية ، وكما يوحي الاسم ،
23:43 يمكن لكل منهم أن يحمل شخصية واحدة. هذا هو مفيد عندما يريد المبرمج قراءة واحدة
23:47 اضغط على زر أو حرف واحد في سلسلة بدون استخدام متغير سلسلة. محدد
23:51 المثال هو صنع لعبة مسيطر عليها بواسطة لوحة المفاتيح. يحتاج البرنامج إلى الاعتراف
23:55 الشخصية التي يتم الضغط عليها وترجمتها هذا للقيام ببعض الوظائف. الآن
24:00 يمكن أن تحتوي السلاسل أيضًا على حرف واحد ، ولكن حرف لا يمكن أن تحمل أكثر من حرف واحد لذا استمر
24:03 هذا في الاعتبار عند تحديد المتغيرات.
24:05 الآن ، لماذا تكون المتغيرات مفيدة للغاية؟ حسنًا ، يجري قادرة على تخزين المعلومات بتنسيق
24:10 يمكن الرجوع إليها بسهولة لاحقًا أمر ضروري عن أي برنامج جيد. في كثير من الأحيان في الرمز كنت
24:15 سوف ترغب في تتبع أشياء مثل كاسم أو نتيجة للمستخدم ، وذلك من خلال الإنشاء
24:19 متغير يسمى "name" أو "نقاط" يمكنك تخزين هذه المعلومات في هذا المتغير
24:23 ثم الرجوع إليها أو الإضافة إليها أو تعديلها عليه. أيضا ، في كثير من الأحيان ، سيكون البرنامج
24:27 لأخذ مدخلات من المستخدم ، والتي لا يمكن تكون مبرمجة مسبقا في التعليمات البرمجية ، وبالتالي
24:31 مطلوب متغير لتخزين المعلومات. قد يعتمد البرنامج أيضًا على العوامل التي سوف
24:35 التغيير مع تقدم البرنامج ، حيث حالة متغير مطلوب مرة أخرى. أيضا،
24:40 أخذ هذه المتغيرات ومعالجتها ضروري جدا لتنفيذ العديد من
24:43 المهام التي تريد أن ينفذها البرنامج ، على سبيل المثال ضرب المتغيرات أو
24:47 سلسلة متغيرات متسلسلة. المتغيرات العامة هي العمود الفقري لأي برنامج جيد وأنت
24:52 تجد نفسك تستخدمها كثيرًا إذا أردت كودًا نظيفًا وفعالًا ، لذا من الأفضل ذلك
24:56 تتعلم أنواع المتغيرات التي تحتاجها للاستخدام ومتى.
24:59 حتى الآن نعرف كل شيء عن مختلف أنواع متغيرة وتحدثنا عنها
25:02 قليلاً ، الآن سنتعمق أكثر إلى ما يحدث عندما نحدد بالفعل ،
25:06 أو إنشاء متغير ، كيف نشير إليه ، وكيف يمكننا معالجتها لبرامجنا.
25:12 للبدء ، دعنا نراجع ما يحدث متى نحدد متغير. الآن عندما نكتب
25:16 سطر التعليمات البرمجية الذي يهيئ متغير ، ويتم تنفيذ هذا الرمز ، الكمبيوتر بشكل أساسي
25:21 يخلق مساحة صغيرة في الذاكرة التي يخزنها اسم المتغير الخاص بك ومحتوياته بحيث
25:26 يمكن الرجوع إليها لاحقًا. عودة إلى مثال لدينا صندوق من الورق المقوى. فكر في هذا على أنه
25:32 إذا كان لديك مرفق تخزين ، وقمت بعمله صندوق جديد من الورق المقوى بعنوان "الاسم" و
25:37 بداخله تضع قطعة من الورق بها كلمة "NullPointerException" عليها.
25:42 الآن ، في أي وقت تريد معرفة المحتويات من مربع اسمك ، يمكنك ببساطة أن تنظر في الداخل
25:46 ونرى أنه يحتوي على محتويات "NullPointerException". هذا ما يفعله الكمبيوتر ، باستثناء
25:52 منشأة التخزين هي الذاكرة ، الصندوق متغير ، ومحتويات الصندوق مهما كانت
25:59 تم تعيين المتغير ليكون مساوياً لـ. في أي وقت تريد معرفة محتويات متغير الاسم ،
26:04 يمكنك ببساطة الاتصال به وسوف يقوم الكمبيوتر بذلك سحب المعلومات المخزنة في ذلك
26:09 متغير بها واستخدامه كيف يرى المستخدم لائق بدنيا.
26:13 شيء آخر يجب ملاحظته بسرعة هو ذلك يمكنك في الواقع صنع متغير بدون وضع
26:17 المعلومات الموجودة بداخله. هذا سيكون مثل إذا قمت ببناء صندوق جديد من الورق المقوى ، أعطى
26:22 انها تسمية مع شاربي ، ولكن لم يفعل ذلك ضع المعلومات بداخله. أنت ببساطة
26:27 توفير هذه المساحة في المستودع الخاص بك لوقت لاحق. يمكن أن يكون هذا لأنك تريد تخزين المعلومات
26:33 في وقت لاحق على الطريق ، أو إذا كنت ذاهب لاستخدامه لتخزين المعلومات المقدمة
26:37 لك من قبل المستخدم ، وفي هذه الحالة لا يمكنك أعطه معلومات لأنك لا تعرف
26:41 ما سيدخله المستخدم. فقط لاحظ أنه إذا حاولت الإشارة أو الإشارة إلى متغير
26:47 التي لا تحتوي على أي معلومات ، ستحصل على ما يعرف باسم NullPointerException ،
26:52 الذي على الرغم من كونه اسم رائع ل قناة يوتيوب ، هو شيء أنت بشكل عام
26:55 تريد تجنبه عند البرمجة.
26:57 الآن ، لغات البرمجة تسمح لنا بذلك بعض الأشياء الرائعة مع هذه "الصناديق"
27:01 التي أنشأناها. على سبيل المثال ، دعنا لنفترض أننا أنشأنا المتغير الثاني "channelName"
27:07 وبدلاً من تعيينه يساوي "NullPointerException" ، بدلاً من ذلك ، قمنا بتعيينه على قدم المساواة مع ما أنشأناه بالفعل
27:12 متغير "الاسم". هذا لا يخلق مساحة في الذاكرة لهذا المتغير الجديد ؛ ومع ذلك،
27:18 يشير ببساطة إلى نفس موقع الذاكرة أنشأنا بالفعل من أجل "الاسم"
27:23 متغير. العودة إلى مرفق التخزين لدينا على سبيل المثال ، قد ترغب في ذلك بدلاً من الإنشاء
27:27 مربع جديد كامل بعنوان "اسم القناة" وتخزين ورقة بالكلمة
27:31 "NullPointerException" عليه ، بدلاً من ذلك ببساطة إضافة تسمية أخرى أسفل "الاسم"
27:37 مربع بعنوان "اسم القناة". الآن لدينا متغيرين ولكن كلاهما يشير إلى نفس الشيء
27:43 المحتويات ، كونها السلسلة "NullPointerException". نقوم بذلك عادة لتوفير مساحة في الكود الخاص بنا
27:48 للأشياء التي نعرف أنها ستحصل عليها نفس القيمة.
27:52 يمكن تحديث المتغيرات في جميع أنحاء الخاص بك الشفرة. على سبيل المثال ، لنفترض أن لديك "عمر"
27:56 المتغير ، وداخله كان العدد الصحيح 17. ثم احتفلت بعيد ميلاد وأردت
28:02 لتحديث عمرك. كل ما عليك القيام به هو مرجع المتغير ، وجعله يساوي
28:06 whatever new integer you want the variable to hold, in this case 18. This would be the
28:12 same as having a box labeled age, with a sheet of paper reading 17 inside of it, and then
28:16 taking that piece of paper out, erasing 17, replacing it with 18, and then placing it
28:22 back into the box. Doing this, we are able to easily update the contents of our variables
28:27 throughout the code as things dynamically shift. As another example, if you were making
28:31 an RPG, your character will likely have stats such as attack, defense, mana, etc. As the
28:38 game progressed you could continuously update the variables so that the player could get
28:42 more powerful the further along that they went through the game, and you wouldn't
28:46 have to create new variables. You would just simply need to keep grabbing that box from
28:50 your storage facility, erasing and replacing the numbers on the piece of paper, and then
28:55 continue along with your code. Just keep in mind that these variables are nothing more
28:59 than places in memory in which a certain value is stored, so we can easily update the numbers,
29:04 and their place will remain constant. بعد a code has run its course, the place in memory
29:09 is deleted until you run the code again and the program dedicates space for the variable
29:13 مرة أخرى. Each time you run the code, you're making new boxes in your storage facility,
29:18 and at the end of your code, you destroy them all to make room for new boxes next time.
29:23 Another cool thing you can do with variables is add them, subtract them, multiply them,
29:29 divide them, and even modulus them. الآن هذا mostly only works for integer variables as
29:32 multiplying and dividing strings doesn't make too much sense. But if you were making
29:33 a calculator app and you stored the first number the user entered as num1, and the second
29:39 as num2. You could then multiply num1 and num2 together, and either print them, or store
29:45 them in a new variable entitled result. ثم، each time you run the program, the user could
29:50 input new numbers into the num1 and num2 variables, and they would simply be set to those new
29:55 integers and return the result that corresponds to those specific numbers. This allows for
30:02 you to keep easy track of which numbers are which and what's going on in your program
30:07 which is extremely useful. Also, while you cannot subtract, multiply, divide, or take
30:12 the modulus of strings, you are able to add معهم. Let's say you had a string Str1 with
30:19 the contents “Hello “ and a Str2 with the contents “there”. You could add Str1
30:26 and Str2 to create a string that had the contents “Hello there”, either storing it in a
30:31 third variable or printing it out to the console.
30:34 The last topic we'll be covering on the topic of variables is the naming conventions
30:38 of a variable, which albeit may seem odd, but it's extremely important when trying to
30:43 read your code so we will be covering it now. Now, variables have to be one continuous string,
30:49 and so if you wanted to make a variable that stored the player score, you'd have to find
30:53 some way to combine the words player and score, since you can't have the phrase “player
30:58 score” be the name of a variable. All programmers have their own personal preference when it
31:02 comes to naming variables, but the one we will be using on this lecture is called CamelCase,
31:07 which is the process of not capitalizing the first word, but capitalizing every word that
31:11 follows it. Going back to the player score example, using the camelCase method, the variable
31:17 would be called playerScore. This allows us to easily identify each word and becomes really
31:23 useful for long variable names like thePlayersScoreBeforeFinalBoss”, whereas if we just type it out without capitalization,
31:31 it would be really confusing. This will help a ton when you start to find bugs in your
31:38 code and need to quickly scan your program to figure out whats wrong, and adds to the
31:42 overall readability of the program. آخر programmers might use different naming conventions
31:48 like using underscores to separate the words in a phrase, but for now we'll be sticking
31:53 with camelCase.
31:54 Next, we'll be moving on to conditional statements, which at their core, are statements
32:00 that change the path of our code depending on certain conditions. For the sake of keeping
32:04 things simple, for this section, red lines will connote that our code will NOT be following
32:07 that specific path, and green lines will mean that our code IS following that path.
32:12 The main type of conditional statement that programmers use is the if statement, and this
32:17 will show up countless amounts of times in any program you write. It is as simple as
32:21 it sounds: if some condition is true, and usually the condition will be enclosed by
32:27 braces, then carry out the instructions located within the if statement's brackets. Else,
32:33 do another thing. Now, brackets are used in most programming
32:36 languages to indicate a segment of code which will run. It works like this, if the condition
32:42 in parentheses is true, then all of the code contained within the brackets will run, and
32:47 if the condition in the parenthesis is NOT true, then it will skip over all of the statements
32:51 within the brackets. A quick note is that while this is the case with most programming
32:56 languages, some; like Python, use colons and white space to determine where a piece of
33:01 code starts and ends, but for the sake of this series, we'll be using curly braces.
33:07 Now, the condition within the parenthesis can take on thousands of different forms such
33:12 as if the value the string variable Name is equal to “Steven” or if the player's score,
33:17 stored in an int variable, is greater than 5, the list goes on and on. Each of these
33:22 statements is evaluated as a boolean, which you will remember from when we talked about
33:26 variables is either true or false. If the boolean is true, we run the code inside the
33:32 curly braces, if it's not, we pretend everything inside the curly braces never existed and
33:38 move on with our code.
33:40 The if statement comes with two more additional statements that can go with it: else if and
33:45 آخر. Else if is a conditional statement used directly after an if statement, and carries
33:50 out mainly the same function as an if statement. However, the else if statement will only be
33:55 evaluated if the preceding if (or else if) statement is bypassed due to its condition
34:01 being false. So we would run through it like so, if something is true, we would run the
34:07 code inside of that statement's curly braces. Else, if that something is not true, BUT another
34:12 statement inside of parentheses is true, we would then run THAT code segment. And if neither
34:18 of them are true, we would skip both segments of code and move on in our program.
34:22 This is a hard concept to wrap heads around so let's do an example. If we had a program
34:27 that evaluated the if statement if (age = 10), we could then have a statement under that
34:32 which stated else if (age = 12). Now, if the age variable was 10, which we can see from
34:38 the example it is, then the code immediately following that conditional statement in the
34:42 brackets would run. The else if statement we made would not even be tested since we
34:46 know it is going to be false, and thus the print statement inside of THAT conditional
34:49 statement's brackets will be ignored, and the code will move on to the rest of the program.
34:54 Now, for example, let's say we changed the age variable to be 12 instead of 10. Now,
34:59 instead of the first conditional statement being, true, it actually evaluates as false,
35:02 since age no longer equals 10. So what we do now, is first skip over the print statement
35:07 which prints out that the age is 10, since it's not. And now we evaluate the else if
35:11 بيان. We check if age is equal to 12, which again it does, and so now we run all
35:15 the code inside of that conditional statement before finally moving on to the rest of the
35:19 program.
35:20 So as a review, we check the initial if statement, if it's good we run all code within that
35:25 if statement's curly brackets and move on with our program, if the initial if statement
35:29 is NOT true, we then move on to any else if statement's and evaluate if THOSE conditional
35:33 statements are true. We can have as many else if statements as we want, although this could
35:37 lead to clutter amongst your code so we'll talk about some alternatives later on to help
35:40 this out. Now that takes care of the if-else statement, so now we'll move on to the else
35:44 بيان.
35:46 The else statement once again comes after an if or an else if statement, and will carry
35:50 out its instructions no matter what, as long as the preceding statement/statements are
35:54 evaluated as false. If we went back to our previous program, we could add an else statement
35:59 which would only have the code in its brackets run if the age variable wasn't “10”
36:03 or “12”. This would catch all cases of the program that didn't fit our parameters.
36:07 It's good practice to ALWAYS have an else statement at the end of your conditional statements
36:10 to catch any weird cases that may come up in your program.
36:13 Now remember back to the fact that we can have thousands of else if statements, after
36:17 a while that can get pretty cluttered, and so another very useful conditional statement
36:21 which helps circumnavigate this problem is the switch statement. A switch statement is
36:24 functionally similar to many if and else if statements together. You write a switch statement
36:28 in the form of switch (variable), and then below that you write how many cases that the
36:32 variable could be. For instance, if we wrote switch(var), then under it we could write
36:36 out 5 cases that the variable var could be, and then the instructions listed under that
36:39 case to be carried out if the var variable is equal to that case.
36:43 Now switch statements are different since instead of using brackets, they use a colon
36:47 to signify the start of a set of instructions, and a break statement to end it. This is very
36:51 useful because you are able to essentially use many if and else if statements without
36:55 having to write nearly as much. In switch statements, you just always have to remember
36:59 to include a default case at the bottom of the expression to denote any and all cases
37:03 that don't meet the above requirements. This simply catches all of the inputs that
37:06 don't fit within the programs main cases. It's very similar to an else case at the
37:10 end of an if-else chain.
37:11 Now, why are these statements so useful? Well, many times, programmers want their programs
37:16 to function differently depending on different conditions. For instance, a program could
37:20 function differently depending on the information that the user inputs, such as allowing a user
37:24 to use a program or not use a program if they are above or below 18 years old respectively.
37:29 Or in say a video game, if a user's experience level is above a certain threshold we might
37:32 want to give them harder opponents to battle. Another example could be a program which changes
37:36 the color scheme depending on the time of يوم. Or even more simply, if a user presses
37:40 a button that is meant to move on to another screen in an app, the programmer would only
37:44 want the app to change screens if the user clicks that button. A program without conditional
37:48 statements would do the same thing every time, and would be very primitive compared to one
37:51 that can change depending on its conditions.
37:54 So now that we know how to make and use variables, how to compare them, and what we can do with
37:59 those comparisons, let's move on to another foundational concept of computer science:
38:04 arrays.
38:06 Now we've already talked about variables, and how great they are for storing singular
38:09 bits information for making our code more simplistic, but one of the biggest drawbacks
38:14 that come with variables is their inability to hold more than one piece of differing information.
38:19 For example, let's say you're making an app which allows users to create a grocery
38:22 قائمة. Well there's no real easy way to create lists using variables, because it's not like
38:28 you can have one variable store the names of 7 or 8 different food items. تذكر،
38:34 we can only put one piece of paper in our cardboard box; no more. And besides, even
38:39 if you were to add multiple items to one string variable, you still would have a lot of trouble
38:43 doing simple tasks you might want from a list like searching through it or splitting it
38:48 or even deleting items from the list when you're done with them. This is the problem
38:52 that using arrays solves for us.
38:55 An array is, as you may have guessed by now, a list. You can have an array of integers,
39:00 an array of strings, and even an array of other arrays which is something we'll cover
39:04 in a minute. Programmers use arrays when they want to store a lot of variables containing
39:08 information that is all related to each other, such as a grocery list or a high score list
39:13 in a game. Think of arrays as a column in excel or google sheets. You have the title
39:18 at the top and then below it are a bunch of bits of information which all relate to the
39:22 title. Arrays are super useful when programmers want to store a lot of information that can
39:27 be easily searched through because programmers have developed methods of breaking down and
39:31 using arrays to find specific information in arrays full of thousands of different variables.
39:36 As an example to show just how useful arrays are, let's say you're a startup company
39:40 that owns an app that has 100,000 users. كل time a user wants to create a new account,
39:45 they input the username they want and then your program will have to check to make sure
39:48 the account name hasn't already been taken. Doing this requires you to search through
39:53 the information of all 100,000 of your users to see if that username has an account with
39:57 your service. An array would be able to contain all of this information and make it easy to
40:02 search through and find out if the account name has been taken with little to no delay.
40:08 Now the single most important thing to note about arrays is how you reference each element
40:12 of the array within them. Let's create a basic array called numbers, and inside of
40:16 it put the digits 1-10. Now when we want to refer to each cell in this array, we call
40:22 upon its “index”. An index is just a fancy way of saying that numbers are placed within
40:27 the array. Now you would think that the first integer in this array would be the first index,
40:32 the second would be the second index and so on, but that's not the case. In computer
40:37 science, programming languages refer to the first cell as the 0th element in the array.
40:43 This means that if we were talking about our array of numbers we just made, the number
40:47 4 would actually be in the 3rd index, 5 would be in the 4th and so on, so instead of starting
40:52 our count from 1, we start from 0. It's extremely weird and confusing but it's one
40:57 of those programming quirks you are going to have to memorize and commit to memory.
41:01 If you were to not follow this nomenclature and you refer to the last element in this
41:04 array as the 10th, you get what is referred to as an “out of bounds” error, since
41:09 you are trying to reference the 10th element, but there is no 10th element. What you're
41:13 actually trying to do is reference the 9th.
41:16 Another extremely important thing to note about arrays has to do with their size. متى
41:20 you initialize an array, you can do it either one of two ways. You can either populate it
41:25 with the elements that you want contained in the array right then and there, creating
41:29 and filling the array at the same time, or you can define how many elements you want
41:34 in the array-essentially the arrays size- and then populate it with elements later.
41:40 This is because when we initialize an array, it creates a space in memory that has a size
41:44 of exactly what you give it, no more no less. This is great for when we want to access elements
41:50 in the array because we can do so instantaneously, but the one downside is that we can't increase
42:00 the size of the array later on, all array sizes are final. Think of it like setting
42:05 up a bookshelf with books. By populating a bookshelf with a certain number of books and
42:11 then moving on and filling the next shelf with different books. We have no way to go
42:15 BACK and add books to that first shelf without shifting everything. Once we decide how much
42:20 space to dedicate space for an array in this case, there's no way to ADD more space.
42:25 Once again because this is extremely important to remember, this means that once an array
42:29 has been defined, there is NO WAY to change the size of it. If you have an array titled
42:34 “Names” with a size of 8, and you try to add another name to the array you will
42:39 receive an error, so be careful when messing around with array sizes. Of course, you can
42:43 always go back at the start of the code when you initially MAKE the array and allocate
42:48 more space to it if you find out you need more space to hold items, but once it's
42:54 defined, you CANNOT change its size.
42:59 Another small thing I want to touch upon really quickly is that when you initialize an array,
43:03 you must determine which type of array it is right then and there. For example you have
43:07 to specifically say it will be an array of strings or integers when defining it, and
43:12 also you're not allowed to mix and match, meaning you can't have an array full of
43:16 integers with a few strings and some doubles thrown into the mix. They have to be all the
43:20 same type.
43:21 Now the last thing we're going to cover on arrays is a little funky, and that is the
43:25 practice of putting arrays inside of arrays. If you make an array of arrays it's referred
43:29 to as a 2D, or 2 dimensional array. يفكر of these as matrices if any of you have taken
43:35 algebra classes. Now If you haven't, think back to our google sheets example but instead
43:40 of just columns, we would add rows as well. So now, each element in our array wouldn't
43:45 simply be just a String variable or an Integer variable, but an entirely new array with its
43:50 own set of values and elements.
43:53 The way we index these is mostly the same, except we would have 2 numbers to index instead
43:57 of 1. We start with the row and then the column. So a number in the position (0,2) would be
44:04 in the first row three columns down, in this case the name Clint. A number in the position
44:10 (1,1) would be two rows down and 2 columns across, in this case the name Chris. You get
44:16 the idea. Now you can also make 3-dimensional arrays by putting an array inside an array
44:22 inside an array, but that's a little above what we're going to be covering so I'm
44:25 gonna cut it off there.
44:26 Next up we're going to be talking about loops, so what exactly are loops?
44:30 Next up we're going to be talking about loops, so what exactly are loops?
44:33 Next up we're going to be talking about loops, so what exactly are loops?
44:37 Next up we're going to be talking about loops, so what exactly are loops?
44:41 Next up we're going to be talking about loops, so what exactly are loops?
44:46 Well as you could probably tell by that statement right there, a programming loop is a statement
44:49 that is used to run certain instructions repeatedly, just like how the opening statement of this
44:53 topic was repeated 5 times. Loops are very useful for a variety of reasons. على سبيل المثال،
44:58 imagine you want to print something 15 times. Sure, you could just copy and paste the print
45:02 statement 15 times. But this is really annoying to have to do, and becomes even more unrealistic
45:06 when that number goes up to, say, 100 or so. Now what if instead of rewriting the same
45:10 instructions over and over again, you could simply place the print statement inside of
45:14 a loop, and it will occur as many times as you would like, that's the power of loops
45:18 baby. With loops we're able to repeat parts of code multiple times. Now there are three
45:22 different types of loops that we will be discussing اليوم. And up first is the for loop.
45:27 A for loop is very useful for situations described above, where you would like to carry out a
45:31 certain set of instructions numerous times. The syntax for a for loop varies depending
45:36 on the language, however it usually consists of three parts. An integer value, a condition
45:40 which the integer value must meet in order to exit the loop, and an operation to modify
45:44 the integer value after the instructions inside of the loop are completed. Each time the for
45:48 loop runs, the operation you set will be performed on the integer, and as long as that integer
45:52 still meets the condition you set, usually being greater than or less than a constant
45:56 value, the for loop will continue to run.
45:59 Eventually, when the integer has been modified by either increasing or decreasing it to the
46:03 point where it no longer meets the condition, the for loop will terminate and the code will
46:06 continue to run. For example, let's say our integer value was i and we set it equal
46:10 to 0, then we set the conditional statement as i being less than 3, so basically we're
46:15 saying that as long as i - the variable we just created - is less than 3, continue running
46:19 the instructions contained within the loop. Finally, we make the operation i + +, meaning
46:24 each time the loop runs we will increase it by one, and inside the loop let's just put
46:27 a simple print statement.
46:29 Now let's run through the loop. We start with i = 0, 0 is less then 3 so we enter the
46:35 loop and print out Hello World. Now that the instructions are done we add 1 to i making
46:39 it 1. Moving on, 1 in less than 3 again, so we once again enter the loop and print out
46:45 Hello World. Again, we add 1 to i, making it 2 now. 2 is still less than 3 so we enter
46:50 the loop again and print out hello world. Finally, we add 1 to i once again and it becomes
46:55 ثلاثة. 3 is not less than 3 though, it is equal to 3, and so we don't enter the loop
46:59 and it terminates, moving on to the next segment of code. This is a simple example, but you
47:03 can extrapolate it across programming to fit احتياجاتك.
47:06 Now when using a for loop you have to make sure to set up a condition that, given the
47:10 initial integer value and the operation, will at some point not be met, to avoid creating
47:14 an infinite loop and crashing your program. An infinite loop occurs when you give a for
47:18 loop a condition which will always be met given the parameters of the program, and so
47:21 the software crashes. For example, a for loop beginning at 10 and checking if i is ever
47:26 less than 0, and then adding 1 to i at the end of the loop will never terminate, since
47:29 i will just increase infinitely.
47:32 After the for loop is the very similar for each loop. A for each loop (or a for-in-list
47:38 loop, in python) is used for iterating through arrays or lists. Essentially the loop will
47:44 go through each element in the array and carry out some set of instructions for each value.
47:50 If you would like to read all of the elements in an array and compare them to some value,
47:54 or perform some operation on them, a for each loop is extremely useful. So for example,
48:00 we could have a for each loop which iterated across an array and simply printed out the
48:04 value of each array location.
48:07 Next up, we have the while loop. A while loop will continually carry out its instructions
48:11 while a conditional statement given to it is true. This can be as long as a certain
48:14 variable is true, as long as a number is less than another number, or while a value is still
48:18 equal to another value. While loops are different than for loops in that the loop is not contained
48:23 within one statement, but stretched out and will continue to run so long as its condition
48:26 is true.
48:28 Like a for loop, you can make the condition such that it will eventually return false
48:31 and exit the loop, however while loops will not crash your computer should you create
48:35 an infinite loop. In fact, it is very common for while loops to run infinitely, as, for
48:40 certain programs, you would like the program to continually be iterated through instead
48:43 of running once, all the way through until you exit out of the program.
48:47 When programming a game, for instance, a while loop would be used to iterate through your
48:50 code, continually refreshing the screen as the game runs. From there you could perform
48:54 operations on the screen to make the game playable. Creating an infinite while loop
48:58 would simply be done using the syntax while(true), as the condition true will always be evaluated
49:02 as true.
49:03 Finally, I'd quickly like to cover an extension of the while loop, the do-while loop. Do-while
49:09 loops are very similar to while loops, except they will carry out their instructions at
49:12 least once, even if the condition is false, and then will carry on like a basic while
49:16 loop. Essentially, the conditions inside the loop will run AT LEAST once, and then if the
49:20 condition is still met they will run again and function as a normal while loop.
49:25 As you can see, loops and their many varieties have some extremely useful functions. Using
49:30 them, you are able to perform an operation many times in a row, you can iterate through
49:34 arrays and lists, and overall decrease the clutter of your code.
49:39 Next up, we're going to take a break from learning about common programming statements,
49:42 and dive into what happens when the code we write doesn't work. More specifically, we'll
49:46 be covering the different types of errors that can occur when you're programming,
49:50 and what causes them.
49:52 Now when you're writing code, you have to understand that things aren't always going
49:55 to go the way you expected them, and sometimes the program doesn't always work as you had
49:59 intended it to. We programmers call these errors and while annoying, they are always
50:04 going to come up in computer science and so it's best to learn what they are and how to
50:08 deal with them. Often referred to as “bugs”, errors in scripting languages can be narrowed
50:13 down to one of three “types”: syntax, runtime, and logic, all three of which we
50:19 will be covering in today's video.
50:22 To kick things off, let's talk about syntax errors. These are usually the easiest of the
50:27 3 to solve since they are oftentimes something that can be fixed within seconds. If you remember
50:31 back to earlier in the video when we talked about syntax and programming rules, we said
50:35 that if you were to break the programming rules, or syntax, that it would result in
50:39 an error. Well that's what syntax errors are, parts in your program where you fail
50:44 to meet the programming rules and so the computer doesn't know how to interpret your code.
50:48 This can be anything, from forgetting a semicolon at the end of a statement in java, accidentally
50:53 defining a variable with two words instead of one, or even just misspelling the word
50:57 String when you're trying to define a string variable. Lucky for you guys, these errors
51:01 are extremely easy to fix since you just need to figure out where the error occurred and
51:06 what the syntax rule you broke was. Now thinking back to IDE's, we mentioned that IDE's
51:11 are so useful because they do precisely that, they underline syntax errors and usually provide
51:16 helpful hints as to how to fix them. يفكر of syntax errors as small misspellings or
51:21 grammatical errors in an essay you're writing, annoying; yes, but not the most infuriating
51:26 things. Another useful thing about IDE's when it comes to syntax errors is that the
51:31 program will actually restrict you from running the code unless all syntax errors are cleared,
51:36 making them even easier to identify and fix.
51:40 The second type of error we will be covering is the runtime error. These errors don't
51:45 show until you actually “run” the code, hence the name “runtime” error. Runtime
51:49 errors are caused by a statement in your code that SEEMS seems logically sound, but the
51:54 computer physically has no way of computing it in a reasonable amount of time. The most
51:59 common of these errors is one which we've already talked about; the infinite loop. مثل
52:03 a refresher/example, think of an infinite loop like this. Say you sat your friend down
52:08 in front of the TV, put on the Office on repeat, and told him he could leave as soon as Michael
52:13 made a “That's what she said” joke. Seems pretty simple right? WRONG, because
52:17 instead of putting in the Office, you put in FRIENDS on blu ray. No michael, no inappropriate
52:23 joke, meaning your friend would be sitting there for the rest of his life probably confused
52:26 as to why Dunder Mifflin looks so much like a coffee shop. This is essentially what happens
52:28 with the computer, you give it some condition that it has to complete before the program
52:32 can terminate; however, you give it no feasible way to finish that task. This puts the computer
52:38 in error mode and most likely will crash your program, as the computer desperately tries
52:42 to complete the condition you gave it. مثل a computer example, if we try to have a program
52:48 terminate when an integer i is no longer greater than 99, but i is initially 100 and only increases,
52:56 the loop will never terminate and the program will crash. To avoid these, you generally
53:01 want to think through the flow of your code before running it -especially with loops-
53:05 to make sure that all of your statements can be completed by the computer. Carefully planning
53:10 out your code before you begin writing it is an extremely useful practice, and something
53:14 we'll be covering towards the later part of this video.
53:18 The final type of error that we will be covering is a logic error. This error is also pretty
53:22 self-explanatory. A logic error occurs when the code runs smoothly without any runtime
53:27 or syntax errors, but the result that you get isn't what you wanted. فمثلا،
53:32 let's say you had a calculator app, and you wanted to instruct the program to add
53:35 two numbers, except it multiplied them instead because you used the multiplication symbol
53:40 on accident. This leads the sum to be 36 instead of 13. Nothing went wrong with the code syntax
53:47 or runtime wise, the code runs just fine, it just doesn't work as you intended it to.
53:53 These are often the hardest types of errors to debug since most of the time, you'll
53:57 have no idea why the code isn't working, and certainly not any idea of how to fix it.
54:02 This is why it's a good idea to test your code incrementally, don't wait until you've
54:06 been programming for an hour before testing your application, or else you'll run into
54:10 a lot of logic errors. Logic errors can be extremely frustrating and could cost you a
54:15 lot of time, making them a huge pain, but if you know how to effectively debug your
54:19 code, you'll be just fine.
54:23 Speaking of debugging your code, that brings us straight into our next topic, which is
54:26 how to debug your program.
54:28 Now, let's say you have written a program. You think it's ready, and you're ready to
54:32 test it. You've been working hard on this, and you're excited to see it in action.
54:35 You run the program, and wait for it to run smoothly and efficiently. Only, it doesn't
54:40 عمل. You have encountered one of the three errors we just mentioned. You really want
54:43 this code to work, but how? This is where debugging comes into play.
54:47 If the code is giving you an error, then the first thing you should do is read the error.
54:51 Oftentimes, for syntax and runtime errors the IDE will print an error message out to
54:55 the console. See what line or lines it points to- since those will be the lines in which
54:59 the error occurred- and see if you can understand and fix what it says the problem is. If the
55:05 error isn't clear, or you've never heard of it, then try googling it, there are many
55:09 websites out there such as stackoverflow which serve as forums to ask and answer problems
55:13 with code. Chances are, if you've had a problem, someone else has had the same issue
55:18 and there is likely a tested solution. عادة، when a syntax or runtime error pops up, you
55:23 should be able to find a fix for it fairly easily; however, as I said before, the issue
55:28 may arise from some loophole or oversight in the code you hadn't planned for beforehand.
55:32 Maybe you did something as simple as multiply two variables instead of adding them. These
55:36 are the logic errors we talked about previously. These problems usually won't have red text
55:40 show up to explain to you what went wrong. You'll have to figure it out yourself.
55:45 Now there are a few different strategies you can use in order to track down and fix a logic
55:49 error. First, you can use print statements and the console in order to determine where
55:54 the code is going wrong.
55:56 Imagine you have a conditional statement that will run one segment of code if an integer
56:00 x, is greater than 5, and will run another segment of code if not.
56:04 If, in your program, x is supposed to be greater than 5 when the program reaches this conditional
56:09 but for some reason the program is still printing out “X is small” you could use a print
56:13 statement to help.
56:14 For this problem specifically you could place said print statement before the branch of
56:18 the conditional that would print the value of x. Now when you run the program you know
56:23 exactly what the computer is thinking. Printing out the value of x just before the if/else
56:27 statement will let you know if the variable has the value you want it to have, and if
56:30 it doesn't you know that somewhere above that conditional something went wrong and
56:34 x was set to a value you didn't want it إلى. In this case, x is equal to 2, which is
56:39 why x is small is being printed out.
56:42 Now we know what the problem is we can track down where and when in the code we modify
56:46 x to figure out the problem. Use print statements to determine where your program goes wrong,
56:51 and then try to track down the cause of these issues and solve them. If you use this strategy,
56:56 make sure you end up deleting the print statements afterwards to avoid clutter in the console.
57:00 The situation described above could also be solved using a breakpoint. A breakpoint pauses
57:05 your program when the line you placed the breakpoint at is reached in your program.
57:09 If, say, you would like the program to run through a certain conditional and set a variable
57:13 based on that conditional, but you are unsure if this actually happens correctly in your
57:16 code, you can place a breakpoint inside the conditional path you want to run.
57:21 Upon the breakpoint being reached, the program will pause, and wait for you to continue it
57:25 through a button press. This signals that the spot in the code where the breakpoint
57:28 was placed, in this case the correct conditional path, has been reached by the program. أنت
57:34 can then continue the program knowing that was or wasn't where an error in your code
57:38 occurred. Breakpoints can be used in conjunction with print statements in order to both pause
57:42 the program, and perhaps view the values of your variables at the moment in time to give
57:46 yourself all the information you could want. You can also have multiple breakpoints to
57:50 help slowly work through your program and determine where the error has occurred. أ
57:56 combination of these two strategies will help you easily determine where in your code you
57:59 have incurred a logic error.
58:01 Next, let's go over what to do if you think you have tracked down the section of code
58:06 that causes the problem. You may think you should delete it, but it's likely you put
58:10 it there for a reason, and you don't want to lose that work if you don't have to.
58:14 Firstly, try commenting it out. Comments are used to markup code and explain their surrounding
58:19 sections, but they can also be used to debug. Anything that is designated as a comment will
58:24 not be read by the program as code, and will be skipped over. Essentially, it becomes something
58:29 that is only there for YOU the programmer to read. The syntax varies from language to
58:34 language, but it usually involves placing some symbols before or around the code you
58:37 would like to be commented. Examples of how to comment in different languages can be seen
58:41 on the screen now. Also, when you comment something, the IDE will grayscale the line
58:46 of code, making it extremely easy to determine what's commented and what is not. Commenting
58:51 code 'deletes' it in the computer's eyes without actually deleting it. If a problem
58:56 is present before you comment a section of code but it is gone afterward, then that section
59:00 of code is the culprit. If you comment part of a code out and there are still issues,
59:04 then move onto another section until you find the culprit. Once you do, you can tweak it
59:09 until it works as intended or delete it entirely and you will have a fully functioning program
59:14 مرة اخري. Hurrah!
59:15 Now that we've talked about what to do IF you've encountered an error and a strategy
59:19 on how to find and fix it, I'd like to talk about some strategies you can use to AVOID
59:23 errors in the first place. Firstly, backup your code frequently. In the event of the
59:28 code completely bugging out and you being unable to fix it, you will want the ability
59:31 to revert to a previous version where the code was still working. If you save frequently
59:35 enough, then you will probably not lose too much work. Version managers like Github or
59:40 Subversion can help with this, as they backup code to an online cloud service in which you
59:45 can easily pull previous versions of the program at any point.
59:48 Also, on top of saving, run your program frequently to ensure that the current version works as
59:53 intended. This accomplishes two things. First of all, it prevents you from saving a backup
59:58 that doesn't work. Secondly, if you encounter a problem, it will be easier to find if you
1:00:03 have only made a small number of changes since the last time you ran it and it worked, and
1:00:07 thus you will only have to look through the new code for problems. If you've spent 5
1:00:10 hours coding and hadn't run it during that time period, it's going to be extremely
1:00:14 likely that at some point during that 5 hour code sesh you messed up, and it's going
1:00:17 to be even harder to figure out where you went wrong. Errors, while annoying and extremely
1:00:21 frustrating, are a fundamental part of making you a better programmer.
1:00:25 Alright, now that we've covered errors for a bit, let's hop on back to programming
1:00:30 statements and talk about one of the most important concepts in computer science, the
1:00:35 وظيفة.
1:00:36 Now, you may not know it, but we've actually been talking about a few functions this entire
1:00:39 سلسلة. Print statements, for loops, and even basic math operations are all examples of
1:00:46 functions, which of course begs the question of what actually defines a function. Well,
1:00:51 a function is a segment of code that can be easily run “calling” the function name
1:00:56 and depending on the type of function, will do something in return. Functions can be called
1:01:01 numerous times, and in numerous places. Essentially they are like wrapping up a segment of code
1:01:07 into a nice present and giving it a name which; when called, will unwrap the present and go
1:01:12 through the code you wrapped up.
1:01:15 For example, the print statements we have been using this series allow us to print something
1:01:19 to the console any time we want are functions. You see, we just “call” the print function
1:01:25 and enter in what we want to be printed to the console, and the computer does it for
1:01:31 us. Behind the scenes, there is actually even more complex code that is in charge of taking
1:01:35 your text and translating it to the console to be printed. The developers of almost all
1:01:40 programming languages realize that you don't want to program something that manually has
1:01:45 to print something to the console through the use of complex programming, and so they
1:01:49 implemented the print statement to reduce the stress and complexity of code on the user,
1:01:54 abstracting it down to a simple line of code. All of that code that is used to print something
1:02:00 to the console is wrapped up like a present and given to us in the form of one line, “print()”.
1:02:06 This is actually the main theme of all functions and the backbone of any good program. Oftentimes
1:02:11 in your program there are going to be sections of code which are repeated and serve the same
1:02:15 purpose, or equations which you want to allow differing inputs of. And so you can use functions
1:02:21 in order to condense these down into singular lines of code to save both time and reduce
1:02:26 clutter on your code. As you will see soon, functions are EXTREMELY powerful and will
1:02:31 definitely be something you utilize all the time in your computer science journey.
1:02:36 The print statement is just one example of functions in everyday code. There are thousands
1:02:41 of functions that are available to you through IDE's. However; because you won't always
1:02:45 use all of the thousands of functions that are open to you in a single program you have
1:02:49 to import these functions from packages found in the IDE, which is something we will cover
1:02:54 لاحقا.
1:02:55 Now, there are four main types of functions in most programming languages, and they are
1:03:00 separated by two defining features: whether or not they take in arguments, and whether
1:03:04 or not they return values. Let's start by separating them by whether or not they take
1:03:08 arguments, but first we have to cover what arguments are.
1:03:13 Arguments are essentially variables that we pass into the function in order to be manipulated
1:03:18 and then either returned back to us, printed to the console, or used in another operation.
1:03:23 Think of functions with arguments like ordering food at a restaurant. If you walked up to
1:03:27 your local five guys and told them you wanted to get food without supplying a type of food,
1:03:32 they would probably look at you confused. You need to tell them what exactly you want
1:03:38 to order so that they can give it to you. In this case getting food is the function
1:03:43 and what you order is being passed in as the argument. Based on what you tell them, or
1:03:49 the argument, they will do something different. You also should note that the argument can
1:03:56 be many different things, it could be fries, burgers, soda, anything really on the menu,
1:04:01 and such is the case with arguments in programming.
1:04:04 This is essentially what happens with the computer, for example, the max function which
1:04:14 takes two integers as arguments and returns the maximum number between the two. Now, for
1:04:20 this function if you don't input two numbers or variables for it to compare, it's going
1:04:25 to throw you an error just like the five guys employee, he doesn't know what you want
1:04:29 to eat since you didn't provide him any arguments, and the computer doesn't know
1:04:33 what two numbers you want it to compare and return since you didn't provide it with
1:04:37 two integers. Arguments are a way for programmers to have one function that can do many different
1:04:42 things depending on whichever variables can be passed through. Arguments add variability
1:04:47 to programming and can help diversify your الشفرة. Thinking back to our five guys example,
1:04:52 a restaurant that only allows one type of food to be made regardless of what you order
1:04:56 isn't going to be very useful or diversified, but if we're able to pass in arguments and
1:05:01 tell them what food we want, our experience can be heightened and more options become
1:05:06 available, which is exactly what happens when you accept arguments in your functions.
1:05:12 Now that we've talked about functions that take in arguments, let's move on to functions
1:05:16 which do not take in arguments, because functions can also be created and used without taking
1:05:20 in arguments and still be incredibly useful. For example, let's say you were making a
1:05:25 text based RPG game and one of the options you give your player is the ability to view
1:05:30 their stats at various points throughout the لعبه. Now every time you come upon an option
1:05:35 and they choose the “View Stats” button, you don't want to have to type out 6 different
1:05:39 print statements for every statistic they may have, your code would get cluttered and
1:05:43 messy very quickly. Instead, what you could do is package the 6 different print statements
1:05:49 in a simple function called printStats(). You don't need to pass any arguments into
1:05:54 the functions since the function will do the same thing no matter what the statistics on
1:05:58 the player are. Now, everytime the user wants to view their stats, you simply call the printStats()
1:06:04 function and voila, the user's stats are printed for them to view. This allows you
1:06:09 to save a lot of time writing out code, but also a lot of space which is extremely important
1:06:14 when your programs begin getting into hundreds and thousands of lines and you want to easily
1:06:19 search through it.
1:06:21 Okay, now that we've separated functions into those that take arguments and those that
1:06:26 do not, let's again split these up into those that return values and those that don't.
1:06:31 Now the thing you have to understand is that when you're making your own functions, which
1:06:35 is something we will be covering soon, you have to choose what your function will return,
1:06:40 if anything at all. Functions are able to return values back to the user whether they
1:06:46 be String variables, integer variables, or even arrays. Now the thing to note about returning
1:06:53 values is that calling the function alone won't do anything. You have to return the
1:06:57 value into something. As an example, the Max function we talked about previously would
1:07:04 return an integer, but in order to do something with it we would have to either set a new
1:07:10 integer variable equal to the result of that Max function, or we can print out the result
1:07:15 of a function, which in this case would just print out the maximum value between the two
1:07:19 integers. Using functions which return values don't do much on their own, you have to
1:07:24 pair it with something in order to gain use out of it.
1:07:28 Let's do another example, let's say you had created a function which took in two string
1:07:32 variables as arguments, combined them using that fancy String math we talked about earlier,
1:07:38 and then returned them as a single string. This combineString function could then be
1:07:43 used to create new String variables since what it is returning is technically a string.
1:07:49 The variable would simply be set to whatever is returned from the combineString.
1:07:55 The last type of function is one that does not return anything, and these are known as
1:07:59 “void” functions. Oftentimes these are like the printStats function we created earlier,
1:08:05 simply used to condense large amounts of print statements that appear often in your code.
1:08:10 These cannot be set to variables since they don't return anything and just get the code
1:08:15 within them run through.
1:08:17 So there you have it, the 4 types of functions. Ones that take in arguments and return things,
1:08:23 ones that take in arguments and don't return something, ones that don't take in arguments
1:08:27 but still return values, and the ones that take in arguments and don't return anything.
1:08:32 Each of these 4 types of functions are useful and unique in their own way and you will probably
1:08:37 find yourself using them all throughout your programming journey, so get used to the different
1:08:41 types of functions and know how to make the most of them, as they are all extremely powerful.
1:08:46 Finally, I'd like to talk about one of the major benefits of functions, which is that
1:08:50 it makes it super useful to make large changes to your code without having to go through
1:08:55 the entire program. Each function call is just a copy of that function's original code,
1:09:01 and so it's very easy to make changes to the function and have it translate to across
1:09:06 your code. Let's go back to our printStats() function and say that you wanted to go back
1:09:11 and add in a new stat that the player can level up through experience in the game. Without
1:09:17 functions, you would have to go back into your code, find every instance that you had
1:09:21 printed out the users stats, and create another print statement to display the new statistic.
1:09:26 However, if you had created a printStats() function like we did a little while ago, all
1:09:31 you would need to do is find where you defined that function and add in a print statement
1:09:36 which displays the new statistic and you're done, bam. Now, every place which had called
1:09:42 the printStats function previously will now also print the new statistic as well. أنت
1:09:47 can see how powerful functions can be if used properly, and we haven't even scratched
1:09:51 the surface yet.
1:09:53 Now, up next we're going to cover how we can import other people's functions that
1:09:57 they've written and use them in our code.
1:10:00 Now before we get technical, close your eyes and imagine you are trying to build a house.
1:10:04 Sure, you could grow your own trees, chop down your own wood, make your own tools and
1:10:09 nails, and build it up from scratch. لكن لماذا do that, when you can simply go to your local
1:10:13 Home Depot and buy these materials that others have already made ready for you. هذا
1:10:17 the main idea behind importing functions into your code. Importing functions allows you
1:10:22 to gain access to libraries of functions that other people have already made for you. هذه
1:10:26 is just as useful as it sounds. يوجد so many functions that are super useful for
1:10:31 any given program that it would take you forever to write them all yourself. Luckily, other
1:10:36 people have already done most of this for you.
1:10:38 In each programming language, you are able to use an import statement to import libraries
1:10:43 of functions into your program that you can use as you write it.
1:10:46 A library is simply a collection of functions that all have the same theme. It may be a
1:10:51 math library, a data analysis library, a library which translates text, or anything that you
1:10:56 can think of really. There is such a variety of libraries for any given language that most
1:11:01 functions you require that are not hyper-specific to your program can likely be found in some
1:11:06 مكتبة. In fact, a good portion of any programmer's job is looking online for packages which can
1:11:11 make his or her job easier instead of handwriting المهام. Now, I can hear you saying, “Wow,
1:11:17 that's sick, how do I do it?” Well, it's quite simple: an import statement.
1:11:23 In most languages, an import statement consists of 3 parts. The library you would like to
1:11:28 import from, the package you would like to import from that library, and then which class
1:11:33 from that package you would like to use. إلى عن على example, we could load up the Java library,
1:11:38 and from there import the util package, short for utilities, and then from that utilities
1:11:43 package import the scanner class, a class which allows us to read information from the
1:11:48 user. A package is simply a smaller sect of functions and methods to help differentiate
1:11:52 between the thousands of methods contained in a library, and class is even more specialized
1:11:57 than that.
1:11:59 Now if you don't know what specific classes you're going to want to pull methods from,
1:12:04 you can use a star * to import all classes within the package you'd like. ومع ذلك،
1:12:08 it can be beneficial to be more specific, and only import the classes you would like,
1:12:12 as it helps with efficiency of the program in the long run. For instance, in python,
1:12:18 the syntax to import a library is import followed by the library name. However, importing an
1:12:24 entire library is more computationally taxing than importing specific functions from a library.
1:12:31 Imagine you would only be using the factorial function from the python math library.
1:12:35 It would be a waste of computing power to import the entire library, and would increase
1:12:39 the load time for your program. For smaller programs, this isn't a big deal, but it
1:12:43 really starts to add up when dealing with larger projects. Therefore, you would instead
1:12:48 use “from math import factorial” or the java equivalent “import java.math.factorial”,
1:12:55 and now have access to that one math command only. This limits the functions that you can
1:12:59 use, however it saves programming runtime. If you decide you want to use another function
1:13:03 that you hadn't planned for, you can always go back and import that too. Many times, if
1:13:09 you try to use a function from a common package and you have not yet imported it yet, the
1:13:13 IDE will prompt you to do so.
1:13:15 If you're trying to figure out which libraries you want to import, think of the functions
1:13:19 you're going to need in your program. Perform a simple google search, and you will probably
1:13:23 run into a package or library that already exists in your IDE that you can use. و إذا
1:13:29 you can't, there are ways to download and import additional projects to fit your needs.
1:13:34 But if after all of that you still can't find a library that contains the function
1:13:38 you are looking for? Well that's a perfect segway into what we're going to talk about
1:13:42 next, which is the basic structure for writing your own functions.
1:13:47 So at this point we've talked about both what functions are and how we can get some
1:13:51 very useful functions by importing functions through packages. But there are definitely
1:13:55 going to be moments in your programming journey where you're going to want to make your
1:13:58 own functions because you want to make one specific to your program and code. لحسن الحظ ،
1:14:04 making your own functions is extremely simple, there are just some basic rules I want to
1:14:08 cover. Now while we've previously used making functions as an example for other topics such
1:14:14 as the playerStats function from a little bit ago, they were extremely abstract and
1:14:18 didn't go in depth into what is needed for an actual function to operate. حتى الآن
1:14:23 we're going to be covering a skeletal system of everything that needs to be included in
1:14:26 a function to get it to work.
1:14:30 Now think back to the 4 different types of functions that we talked about previously.
1:14:34 Functions that do and don't return values and functions that both do and don't take
1:14:38 in arguments. For creating your own functions, we're just going to go down the list and
1:14:42 talk about how to approach creating them, starting with the most basic of the bunch,
1:14:47 one which takes no arguments and returns no values, but before we start that, there are
1:14:53 a few small things I want to note about function naming conventions. The variable naming conventions
1:14:58 we talked about previously also translate over to function names. So you can't have
1:15:03 two word functions and you can't use special characters like periods or commas. Generally
1:15:08 you're going to want to follow the same camelCase style which we talked about in the
1:15:12 variables video.
1:15:16 Alright, so in general for making functions, each language differentiates how you tell
1:15:23 the computer that it's a function. In java you have to define the functions scope, which
1:15:29 is something you don't really need to know unless you're going to become more invested
1:15:32 in java, but basically it tells the computer which parts of code can use the function and
1:15:38 which type can't. For this series all of our functions are going to be public. From
1:15:43 there you then determine which type of function it is, so in this case since it won't be
1:15:48 returning any variables we'll just put void to signify this type of function will not
1:15:52 be returning anything. Finally, you put the function name after those two identifiers
1:15:57 along with a set of parentheses after it like وبالتالي. The parenthesis are where your arguments
1:16:02 would go if you were making a function that took in arguments, but since for our first
1:16:06 type of function we're not incorporating arguments into this function, let's just leave
1:16:11 that blank. All of that is just for Java; Python on the other hand all you do is put
1:16:17 def, short for define, and then the function name with a set of parenthesis. So as you
1:16:23 can see, each language is going to be different, but the main thing we want to remember is
1:16:29 to always add parentheses. From there, we just type what we want our void function to
1:16:34 do within the confines of the function and then close off the loop and we're done,
1:16:38 easy peasy. In Java, the confines of the loop would be whatever is contained within the
1:16:42 curly brackets, and in python it would be until you are no longer indented. At its core,
1:16:47 this is the most primitive type of function we've just made. Something which takes in
1:16:51 no arguments and returns no values, quite similar to the printStats function from earlier
1:16:56 على.
1:16:58 Moving on to the next type of function, creating a void function that takes in arguments. الآن
1:17:03 this process is going to seem very similar to the previous except for one small adjustment.
1:17:08 Remember the parenthesis that I mentioned like 30 seconds ago, well we put any variables
1:17:12 we want the user to pass into the function into these parenthesis, and then when we “call”
1:17:17 that specific function, it will be required to have those variables passed into it. إلى عن على
1:17:22 example, in Java, let's make a function that takes in 2 numbers and prints out the
1:17:26 product of those numbers. We start with the public void plus name of function setup since
1:17:32 again, we won't be returning any values. And now comes the new part. Inside the parenthesis,
1:17:37 you define which type of variables you want to pass in as arguments, in this case an integer,
1:17:43 and then a name for that variable. This name is what you will use to refer to the integer
1:17:48 the user passed in. For this example let's just call it num1. Then if we want to add
1:17:54 another argument, we simply add a comma in between the two and we can make another integer
1:17:58 variable num2 to hold the second number. نحن could do this for however many variables we
1:18:03 want to pass into the function, but for now let's close off the parenthesis and just
1:18:08 print the product of num1 and num2. As you can see, we refer to the two numbers the user
1:18:14 will input to the function as num1 and num2.
1:18:19 Now, whenever we want to call the multiplyNumbers function, we just have to make sure that we
1:18:29 are putting 2 numbers in as arguments. في this case the number 5 becomes num1, and the
1:18:34 number 8 becomes num2. From there we simply run the code and the number 40 is printed
1:18:39 to the console. It's important to note that you can also mix and match variables when
1:18:44 making arguments. So you can have someFunction which takes in a char, an integer, and two
1:18:50 strings all within one function. Pretty neat في رأيي. The last thing I want to mention
1:18:54 about arguments is that when you call a function you have to follow the variables you defined
1:18:58 when making the function. So for our multiplyNumbers function you couldn't put in a string and
1:19:03 then an int. It HAS to be two integers because that's what the computer is expecting to
1:19:08 be passed into the function.
1:19:11 So now that we've gone over how to make functions that don't return variables, we
1:19:14 have to cover those that do, and we'll start with ones that don't take in arguments.
1:19:18 Now the main difference between defining functions that return variables and defining ones that
1:19:23 do not is that in some cases you have to specify that you want this function to return an integer
1:19:29 variable, this is most commonly used in Java, where you would replace “void” with “int”
1:19:34 to tell the computer that you want this function to give something back to you in the form
1:19:38 of an integer. This works the same as if you wanted to return a string, char, or even an
1:19:44 array. You simply replace the word after public with whatever variable you want to be returned
1:19:49 by the function.
1:19:51 The most important thing to remember about making functions that return variables is
1:19:55 that no matter what path your code takes, it MUST return a variable NO MATTER WHAT.
1:19:59 ماذا يعني هذا؟ Well let's say you had some String function in a game and inside
1:20:05 of it there was an if statement where if the player score was above a 10, you returned
1:20:09 a congratulatory message. This works fine if you print the result of this function and
1:20:14 the player's score is above 10. But, if the playerScore was less than 10 then you
1:20:18 don't enter the if statement and then you don't have something prepared to be returned
1:20:22 to the user and so the function is going to throw you an error. You HAVE to have all your
1:20:26 paths covered which may seem simple, but if you're making a function with a switch statement
1:20:31 in it containing high amounts of cases, this can get out of hand quickly. Something I like
1:20:36 to do just to make sure this doesn't happen is put a return statement at the bottom of
1:20:40 the function with a string or an integer so unique that I'm able to tell that the code
1:20:44 is not running properly and can fix it. ال main point I'm trying to get across however,
1:20:57 is always cover your exits and always have a return statement prepared for any case the
1:21:02 user may throw at you.
1:21:03 Another small thing to note is that you can't return one type of variable if you have already
1:21:07 defined the function to return another type. For example you can't return a string in
1:21:12 an integer function or vice versa. The return statement must always match the type of function
1:21:17 بغض النظر.
1:21:19 The final type of function is one that returns variables and also takes in arguments, and
1:21:24 for these all you need to do is combine what we've learned from the previous cases. أول،
1:21:28 you assign your arguments in between the parenthesis, making sure you have also defined what variable
1:21:33 you want to return, and then ensure that no matter what path the code takes that you are
1:21:38 always returning that variable type. ذلك concludes our discussion on functions. مثل
1:21:44 you can probably tell, functions are an extremely vast subject area and require a little bit
1:21:48 of practice to fully understand, which is why later on we'll recommend some websites
1:21:53 you can use to practice these more difficult المواضيع.
1:21:58 Now I'd like to switch gears a little bit and continue our discussion from earlier on
1:22:03 arrays. Arrays, while useful, aren't the only way to store and manipulate information.
1:22:09 In fact, there are a multitude of different ways to store data in computer science including
1:22:14 LinkedLists, Stacks, Queue's, Maps, Trees, and many others too.
1:22:21 Right now; though, I'd like to talk about 2 cool, wacky and zany ways to store data
1:22:26 that we haven't previously covered: ArrayLists and dictionaries. But before we get into those,
1:22:32 let's get a little review/reinforcement of array's.
1:22:35 As you may remember, arrays are basically lists of values that are stored together.
1:22:40 When you initialize an array, you give it a size, and this size is fixed. You won't
1:22:45 be able to increase the size of the array, so when you make an array, it's length is
1:22:48 final. To access the values in an array, you reference them using an index which starts
1:22:54 at 0. What this means is that the first item of an array is not at position 1, it is at
1:23:00 position 0, and it's position is commonly referred to as it's index location. وبالتالي،
1:23:06 to find the nth item in an array, you would refer to it as index location [n-1]. ومع ذلك،
1:23:12 as the size of an array is fixed, you have to be careful to not reference a position
1:23:16 that is beyond the total size of the array, or append too many items to it, as this will
1:23:21 return an error. We also have what are known as two-dimensional arrays,
1:23:26 which is an array containing an array at each of its indexes. Or, you could have an array
1:23:30 containing arrays containing arrays containing arrays containing arrays, depending one what
1:23:34 you're trying to do. Multidimensional arrays can be useful in more advanced programs for
1:23:39 organizing a wide volume of related values. If that's confusing at all, skip back to
1:23:44 earlier for our full discussion on Array's, the time-stamp will be in the description.
1:23:48 Now that we've reviewed array's, let's go over array lists. Array lists (or just
1:23:53 lists, in Python) can be thought of as a growing array.
1:23:57 Earlier, we mentioned how you have to be careful to set an appropriate size of your array and
1:24:01 make sure to only reference and append values such that you remain within the size of the
1:24:06 array. However, with array lists, this isn't مشكلة. After you initialize an arrayList,
1:24:11 it instinctively has a size of 10, but if you append a values such that the size of
1:24:16 the arrayList goes beyond 10 elements, an arrayList will “grow” itself, meaning
1:24:21 that the computer will allocate more memory to the array to increase its total size so
1:24:25 that the new values can be appended. هذه is quite useful when you don't know the
1:24:29 exact number of values that the array will need to store, or want the ability to store
1:24:34 values to your heart's content, such as making a database with an unknown amount of
1:24:38 user's that will sign up.
1:24:40 There is a lot more to uncover when regarding arrayLists, but for this surface-level series,
1:24:44 that is all you pretty much need to know, so let's move on to dictionaries.
1:24:48 Now when we talk about dictionaries, we're not referencing that thick book you probably
1:24:52 have lying around your house which has thousands of definitions. In computer science, dictionaries
1:24:57 are like arrays, in that they store multiple values, however their values are stored very
1:25:02 differently. Rather than being referenced by their position within the dictionary linearly,
1:25:06 each value is tied to another value that is used to reference it, or its “key”. Because
1:25:10 of this, we need to throw away all conceptions of dictionaries as a linear way of looking
1:25:15 at data, since in actuality it is much more fluid and interchanging. Basically, we say
1:25:21 that each position in a dictionary holds a key/value pair. When referencing a value in
1:25:26 a dictionary, you will use it's unique key, and the dictionary will tell you the value
1:25:31 that is tied to it. Think of it like this, each time you add an item to your dictionary,
1:25:36 your computer creates a handcrafted box to store the data, and also custom-makes a jeweled
1:25:40 key, one of a kind, no other like it in the العالمية. This way, there is only one key that
1:25:46 goes to the box that stores a certain bit of information. Because each key must be unique,
1:25:51 reusing a key in a dictionary will result in an error being thrown because having two
1:25:55 keys that are exactly the same would confuse the computer as to what box, or bit of information,
1:26:00 that key leads to. However, you can store the same value in multiple key/value pairs,
1:26:05 since the keys would all be different.
1:26:08 Now like I said, dictionaries are more fluid, making them easier to organize than arrays,
1:26:13 as everything is set up in a more logical manner. That is to say, it is easier to find
1:26:17 the value you are looking for when you are using keys rather than simply referencing
1:26:22 their positions. Let me explain what I mean. Imagine you have a dictionary of prices at
1:26:27 a store where the key is the name of the product and the value is the price of the item. يمكن
1:26:31 apples cost 1 dollars, milk costs 2 dollars, and bread costs 3 dollars. You can see that
1:26:36 in the dictionary, each key is the name of a product, and each key corresponds to the
1:26:41 price of each product. So to find the price of bread, all you need to do is simply call
1:26:45 the dictionary using the key “bread”, and the dictionary would return the value
1:26:48 1. This makes it extremely easy to track values through your code since you're working with
1:26:51 tangible values rather than numbers which don't mean anything to you.
1:26:55 You can also manipulate dictionaries in many the same ways you can manipulate arrays and
1:27:00 array lists. You can iterate through a dictionary and perform many operations and comparisons
1:27:04 on the values. If you want to find the product with the highest price, for example, you can
1:27:09 iterate through the dictionary to find the value that is the highest amongst the grocery
1:27:12 store items.
1:27:13 Arrays, arraylists, and dictionaries are useful in their own right, as are the mass amounts
1:27:18 of other ways to store data, and each boast certain advantages over one another. We already
1:27:23 covered the basics of 3, but since there are so many, we don't have time to go in-depth
1:27:28 into each and every one of them, and so in order to help you grasp the basics of storing
1:27:32 information, we're now going to talk about one of the most important functions needed
1:27:35 to understand arrays, which are searching algorithms.
1:27:38 Now, just as there are many ways to store information in computer science, there are
1:27:43 even more ways of searching through lists. Searching algorithms at their core are ways
1:27:47 in which we can look through a list of values stored in an array, say a patient name list
1:27:52 or a high score list, and find a particular piece of data. The goal of a searching algorithm
1:27:57 is to simply give the algorithm a string or object you want it to find and return the
1:28:02 index of the array that contains that string or object as fast as possible. Now this may
1:28:07 seem simple, but lots of software runs on the backbone of being able to search through
1:28:11 lists extremely quickly, making searching algorithms, and in particular efficient searching
1:28:17 algorithms, an important topic to cover. Additionally, this is the main functionality that arrays
1:28:22 are used for and is the backbone of many of the methods used with arrayLists as well as
1:28:27 many other storage methods, so knowing them will take you a very long way.
1:28:32 Typically searching algorithms are used to return the index of a particular data point
1:28:36 so that it can be used, modified, updated or checked on. For example, if you are about
1:28:42 to check into a hospital run on an array system for patients, the staff must search for your
1:28:46 name in the database and by returning the index of where your name is, they now have
1:28:51 a quantifiable number that they can use to easily check you in, rent out prescriptions,
1:28:56 schedule you for checkups, update your personal information, etc. without having to search
1:29:00 through the list for your name every time.
1:29:03 You may think that there is little difference between searching algorithms, since computers
1:29:07 nowadays can perform millions of calculations per second, but when you're a huge multi-billion
1:29:12 dollar corporation trying to find a certain data point in a list containing thousands
1:29:16 or even millions of data points, small differences in efficiency are going to make or break the
1:29:21 user experience. Even a 1% improvement in efficiency can mean big differences in the
1:29:27 amount of time a user is waiting for a simple task.
1:29:30 Now before we jump into different types of searching algorithms, we must discern between
1:29:34 the two states that arrays or lists can be in, either sorted or unsorted. A sorted list
1:29:40 of information is characterized by some sort of rankable value, whether that be a patient
1:29:45 ID, credit card number, or even by alphabetical values like username's or legal names. An
1:29:52 unsorted list is just some random assortment of related information, not sorted by any
1:29:56 particular order or reason. Some searching algorithms only work for sorted lists, usually
1:30:02 the more efficient ones, and some work for both sorted and unsorted lists, although these
1:30:08 are usually less efficient. If you end up pursuing computer science further, you will
1:30:11 have to deal with both sorted and unsorted lists, so it's good to know common searching
1:30:16 practices for both
1:30:19 Another thing to note is that we determine the efficiency of a searching algorithm based
1:30:23 on both the worst case scenario and the average number of items it must search. We call this
1:30:29 Big O notation, in which each searching algorithm has an equation which takes in the size of
1:30:33 the array as an integer n, and will output an worst-case scenario efficiency value that
1:30:38 we can use to compare with other searching algorithms. We can then also look at how long;
1:30:44 on average, it takes to find an element in a list. Using these two methods allows us
1:30:49 to easily compare how efficient two algorithms are. Alright, now that we've got some background
1:30:54 on searching, let's hop right into it.
1:30:57 The first type of search we'll be talking about is called a linear search and you've
1:31:01 honestly probably used this multiple times throughout your life. Every time you have
1:31:05 to search for your name on a list of people you probably follow the same pattern. أنت
1:31:09 start at the top, check to see if the first name on the list is yours, if it is. عظيم.
1:31:14 If not, you move on to the next name on the list until either you find your name, or you
1:31:18 don't in which case you leave. A linear search works the same way, you start with
1:31:23 the first element in the list, compare it to the value that you're trying to find,
1:31:27 and if they're the same you've found your match and return the index of that element,
1:31:31 and if not you move on to the next element in the list until you either find the thing
1:31:35 you're searching for or you run out of list to check. Seems pretty simple right? هذه
1:31:40 is because linear searches are pretty bad when it comes to efficiency, especially in
1:31:44 the worst case scenario. If the item you're searching for in the list is the last element,
1:31:49 you're going to have to check the entire list of items before you find the one you're
1:31:53 searching for. On average; however, you're going to get it about halfway through the
1:31:57 قائمة. This makes the linear search O(n) worst-case scenario, since in the worst possible case
1:32:03 it will take the entire length of the array, or n, to find the correct value. The linear
1:32:08 search on average will return the correct index in O(n/2) or halfway through the list.
1:32:15 The linear search is great; however, since it can work with both sorted and unsorted
1:32:19 lists, because of the fact that it will eventually cover every element in the list. الأخرى
1:32:25 search we'll cover requires the list to be sorted which may seem like a drawback,
1:32:29 but having a sorted list allows you to use algorithms that are far more efficient than
1:32:33 the linear search. So overall, the linear search is a good basic searching algorithm
1:32:37 for if you have an unsorted list, but if your list is sorted, there are way more efficient
1:32:42 options out there for you, such as the binary search which we'll be talking about now.
1:32:47 The binary search uses a recursive process to break the data in your list down into more
1:32:51 and more manageable bytes, taking advantage of the fact that it's sorted, in order to
1:32:56 find the item you're looking for faster. This one is much harder to wrap your head
1:33:00 around so let's start with an example. دعونا say you have a list of 10 names sorted alphabetically,
1:33:06 like shown on the screen now, and you wanted to find your name within that list. In binary
1:33:11 search you would first look for the middle-most name, in this case the one at the 4th index.
1:33:17 Just a quick aside, since there is no “true” middle, the computer automatically uses the
1:33:24 next one down as the “middle” value. الآن، once you find your middle value, you first
1:33:29 check to see if the name you're searching for at the index you've chosen, if it is
1:33:36 you simply return that index, but 99.9% of the time it's not including right now, so
1:33:42 let's keep going. If the value at the middle index is NOT equal to the one you're searching
1:33:48 for, you check to see if the value you're searching comes before or after the middle
1:33:54 index. For example, if you were looking for the name Brendan and the value at the middle
1:33:59 index was Carl; Brendan obviously comes before matthew alphabetically and since we know the
1:34:05 list is sorted, what we can do now is ignore the entire bottom half of the list and just
1:34:10 focus on the top, since we know that if Brendan is even in the list, it's going to be in
1:34:15 that top half. Now, we simply treat the top half of the list as an entirely new entity
1:34:21 and repeat the process over again. مرة أخرى، we would find the middle-most element of this
1:34:26 new list of names and again compare it to the name you're trying to find. If it's
1:34:30 the name we're trying to find, we return that index, but if not we compare to see if
1:34:34 it comes before or after the middle index. Going back to our example, let's say the
1:34:39 middle index of this new list is AJ. الآن، we know that Brendan comes AFTER AJ alphabetically
1:34:46 so we can now ignore the top half of the list since we know that Brendan is going to be
1:34:52 in the top of our list. Now we repeat this process again and again until we find the
1:34:58 name we are looking for. So for our example, the middle index this time is Brendan, and
1:35:03 that's what we're searching for so we finally would return index 2. In binary search,
1:35:09 eventually the index we compare to our search term will be the same and once it is, we can
1:35:14 return the index and move on. Now if we don't find it, which happens after we have eliminated
1:35:18 the entirety of the list without finding our search term, the algorithm will simply return
1:35:23 a null value to let you know that the item you're searching for cannot be found in
1:35:27 the list. The binary search is way faster and more efficient than the linear search
1:35:33 since we are drastically cutting down the amount of elements we have to look at, making
1:35:37 the program run faster. In almost 99.9% of cases in which your list is sorted, the binary
1:35:44 search is going to return a result faster than the linear search, so if you have a sorted
1:35:49 list, your best option is to go binary. مثل for efficiency, the binary search is O(log
1:35:55 n) for the worst case scenario which can be confusing if you don't fully understand
1:36:00 logarithms, but all you need to know is that it is way more efficient than the linear search.
1:36:04 It's average scenario is actually also O(log n) as well, which again is infinitely times
1:36:10 more efficient than linear.
1:36:12 Now, while there are other types of searching algorithms you can use, these two are the
1:36:17 most common for both unsorted and sorted lists, so we will stop there for now. Up next, we're
1:36:23 going to be covering one of the most confusing and important topics in computer science,
1:36:28 recursion.
1:36:29 Let's start with the most important question: what exactly does recursion mean? In programming,
1:36:36 recursion refers to functions that repeatedly call themselves. Meaning, that in the instructions
1:36:41 that occur within a function, one of the instructions will be a call to that same function you're
1:36:45 already in.In the extremely primitive example on your screen now, you can see we have some
1:36:50 function which, in the confines of itself, calls itself. A recursive function will usually
1:36:55 take into account some integer as an argument, and will use this to carry out some instructions,
1:37:00 modifying the integer that was entered, before calling itself again with that new integer
1:37:04 as its argument.
1:37:05 To better understand these functions, let's discuss the basics of how we go about programming
1:37:10 one of these recursive functions and create one ourselves. A really good easy example
1:37:12 of a recursive function is one which sums all numbers from 1 to n, so let's make a
1:37:17 recursive function that does just that. ال first thing we need is the actual function,
1:37:21 and we're going to make it an integer function which takes in an integer n as an argument.
1:37:26 The reason we do this will be explained later but for now let's move on to the base case.
1:37:31 A base case is simply a definite value which all recursive statements, the ones that are
1:37:35 being repeatedly called as we go through the function, try to get towards. At the beginning
1:37:40 of the function, we test the value that was passed in by the argument against the base
1:37:44 case to see if it is satisfied. Usually, these base cases are some requirements, like if
1:37:48 n, as I described before, reaches a certain value or is equal to a certain value.
1:37:53 It is extremely important that the base case is set to some requirement that n will eventually
1:37:59 meet for the same reason that it is important to avoid infinite loop: we do not want a stack
1:38:05 overflow error to occur. For example, if our base case was to stop calling the recursive
1:38:11 function when n was greater than 100, and if it is not, we call the function again but
1:38:16 with n-1, and we started with n as 99, we would never reach the base case and the recursive
1:38:22 function will repeatedly call itself over and over and over again, subtracting 1 from
1:38:26 n and hoping that somehow it will eventually be greater than 100 until your computer crashes,
1:38:32 not fun. So anyways back to our recursive sum example, let's make our base case when
1:38:38 n is less than or equal to 1. This way, we can start at some positive integer n
1:38:43 and subtract from it until it hits at or equal 1, in which case we can exit the recursive
1:38:49 بيان. رائع. Now, if n is not less than or equal to 1, what we want to do is return
1:38:56 the SUM of both n and then the returning value of our recursiveSum method minus 1. Why do
1:39:03 we add n + the function call? Well let's actually go through the function as if we
1:39:09 were the computer and see why. We start with a call of recursiveSum with n = 3. We know
1:39:15 that 3 is not less than or equal to 1 so now we try to return a recursive sum of n (which
1:39:22 is 3) and the returning value of recursiveSum with an n of 2.
1:39:27 We don't KNOW what the returning value of recursiveSum with an n of 2 is so we have
1:39:32 to go through the function again, only this time n is 2.Again n is not less than or equal
1:39:40 to 1, and so this function will go into the else statement and return…2 plus ANOTHER
1:39:46 recursive statement, in this case the returning value of recursiveSum with an n of 1. So once
1:39:53 again we have to go through the recursiveSum function to get the value that will be added
1:39:57 to 2 and then returned and added to 3 and then returned. Hang in there we're close.
1:40:04 Now in this function, n IS less than or equal to 1 and so we return n, which is 1.
1:40:12 Now we take that n, which is 1, and that is what gets added to 2 in the previous function
1:40:18 call and then returned, so this would return 3. Now this 3 is what gets added to the first
1:40:25 function call, which is three, and so it becomes three plus three which is 6. And FINALLY after
1:40:33 all that time, we get 6 returned from the وظيفة. Which, if you've been following
1:40:38 along at home, 3 + 2 + 1 is indeed 6. Now this may seem like a waste of time since 1
1:40:45 + 2 +3 is not a hard operation. But to those of you saying that I ask you to please give
1:40:51 me the sum of all numbers from 1 to 3,567. الله. Now recursion is a VERY difficult
1:40:58 concept to wrap your head around, so if you're not 100% comfortable with it at the moment,
1:41:03 please rewatch this section of the lecture to better familiarize yourself with it.
1:41:09 Alright cool, now that we have a little background on recursion, let's talk about why it works
1:41:13 so well. Now to understand why and how recursion works, we must first understand what a stack
1:41:19 يكون. A stack is a data structure that contains all of the tasks you instruct your program
1:41:24 to complete. Based on a certain method, your program will then carry out the tasks you
1:41:29 give it.
1:41:30 It's called a stack because if we call start another process before the previous one completes,
1:41:35 the process is “stacked” on top of the other one such as the animation on your screen
1:41:40 is showing now. Programs we write will follow the LIFO structure.
1:41:45 For those unfamiliar with accounting, LIFO means last in first out, or the last item
1:41:50 put on the stack will be the first one removed from it. Essentially, every time you ask your
1:41:56 computer to complete a task, that task is added to the stack, and will be the first
1:42:01 one to be resolved. Think of it like a stack of stones, you can keep adding stones on top
1:42:06 of your pile, but in order to get to one near the bottom, you first have to remove all the
1:42:10 rocks on top of it. Now when your function continually calls itself without end; without
1:42:14 a base case, like in our infinite loop example then the stack will never be resolved, as
1:42:20 items will be continually added to the stack without any of them ever being completed.
1:42:25 In this case, the memory allocated to the stack is exceeded, and a stack overflow error
1:42:31 occurs, resulting in your program crashing. Think of this as if you're doing chores
1:42:38 and before you complete one chore, you get called to do another chore, and then before
1:42:42 you can complete that one you get called to do another one.
1:42:45 Since you keep stacking tasks or chores on top of each other, the stack of tasks will
1:42:51 never be completed and you will probably die before ever finishing any of your chores.
1:42:56 This is the same logic that makes infinite loops crash your program. Recursion works
1:43:00 on these same principles. The initial call makes a second call which is added to the
1:43:05 stack, and now that one must be taken care of first, but in that one another function
1:43:10 is called which gets added to the stack, and so on, until you reach the base case in which
1:43:15 you slowly start going back down the stack.
1:43:19 In conclusion, recursion in general is extremely useful because by calling the same functions
1:43:24 repeatedly it breaks down the problem into smaller sections, and results in the program
1:43:29 being more efficient. Small parts of problems are easier to solve and less taxing to compute
1:43:35 than the entire problem at once, and the computer can combine these small solutions into the
1:43:40 main solution in the end.
1:43:42 Now as we wind down our introduction to programming series, we want to take some time and go over
1:43:47 some of the soft skills needed to be a successful computer scientist since it's not all about
1:43:51 writing code. In fact, many professional computer scientists will tell you that the majority
1:43:56 of their job is spent thinking about code rather than actually writing it. This is because
1:44:01 much of programming boils down to problem solving. How do we optimize this system, how
1:44:06 can we make this feature for our app? ماذا type of movement do we want for our game and
1:44:10 how can we program it?
1:44:12 The harsh truth is that no good program has ever been written simply from the programmer
1:44:15 getting the prompt or idea, sitting down, hopping on an IDE, and starting to write code.
1:44:21 There are many tasks we should go through beforehand in order to plan out our code so
1:44:25 we ensure that when the time comes to program, it's a clean and easy process, and not riddled
1:44:30 with mistakes and bugs. This is where pseudocode comes into play.
1:44:35 Think of pseudocode like this, if you wanted to take a family trip to the grand canyon,
1:44:39 would you simply hop in your car and drive off and figure things out later? No, because
1:44:42 that would be ridiculous. Instead, you would spend some time planning out the trip, what
1:44:48 sites or places do you want to visit? ماذا hotel reservations are you going to have to
1:44:52 make? What kind of things are you going to do when you get there? What routes or highways
1:44:56 are you going to take and why? كل هذه things must be determined out before you can
1:45:00 even think about hopping in your ford explorer. So how does this translate to pseudocode?
1:45:04 Well, think of our family trip to the Grand Canyon as a program. Programmers use pseudocode,
1:45:10 pseudo meaning not real, and code meaning, well, code, as a means to plan out their programs
1:45:15 before they write them, just like how we planned our trip before going. They throw away syntax
1:45:20 and naming conventions for variables and just focus on what they want the program to accomplish,
1:45:25 and how they plan on doing that. Pseudocode is very similar to constructing an outline
1:45:30 for a paper you're writing. You write down the main topics of the essay and plan out
1:45:34 your major talking points, but you don't worry about the nitty gritty details of it
1:45:38 all such as word choice, grammar conventions, and proper formatting. By doing this, we allow
1:45:43 ourselves to think freely and not worry about stressing the small stuff. At least not yet.
1:45:48 Alright, so now that we know WHAT pseudocode is, let's talk about HOW we write pseudocode.
1:45:53 You see, the best part about pseudocode is that it can take the form of many different
1:45:57 things for many different people. Each computer scientist probably has their own methodology
1:46:01 for planning out their code, and since there are probably hundreds of different methods
1:46:04 of writing pseudocode that are out there, today I'd like to focus on 3 popular ones
1:46:10 that I think you might find to be extremely useful.
1:46:13 The first of these are known as flowcharts, and mainly they can be used to think through
1:46:17 the process of a particular function. A flowchart is fundamentally a graphical representation
1:46:22 of a function and how it might flow. Many programmers do this, and lay out the conditional
1:46:28 statements and loops they want as different blocks in the flow chart, connected by arrows
1:46:32 and charting out every path of their function. From there, it's extremely easy to create
1:46:36 test cases and follow them throughout the flow of the function through the different
1:46:40 blocks and arrows. For example, we could have a flowchart that goes something like this.
1:46:45 A user enters a number, and if this number is 8, I want the program to return True; ومع ذلك،
1:46:51 if the number is not 8 then I want to return false. It's a great way to visualize what
1:46:56 the function's overall purpose is and also look for any errors that you may have missed
1:47:00 when thinking about the function, such as a missing path. It also abstracts the programming
1:47:06 statements up to simple blocks, making it easier to modify or change completely. ال
1:47:11 best part is, that when you have finished testing cases you can simply convert the blocks
1:47:16 into statements and you have a well-written function without any debugging.
1:47:21 Another popular pseudocode technique that is used often is to simply write out what
1:47:25 you want your code to do chronologically. Don't necessarily think about what programming
1:47:29 statements and functions you want to use, just jot down, from start to finish, what
1:47:34 it is the program you are writing is going to do step by step. For example, let's say
1:47:39 you're making an app that takes in two numbers and divides them. The pseudocode for that
1:47:43 would look a little something like this. First I want to prompt the user to enter a number,
1:47:48 then I want to wait for the user to input the first number. After I get the first number,
1:47:54 I want to again prompt the user to input a second number. Once they do, I complete the
1:47:59 operation by dividing the two numbers entered and return the result back to the user. هذه
1:48:04 all seems like it would be common sense, but remember that oftentimes we're not going
1:48:08 to be working with simple multiplication functions, we may be working with full-scale games, algorithms,
1:48:14 or user interfaces with many different options. This method allows you the programmer to not
1:48:20 get bogged down with the syntax and conventions you have to follow, you're simply making
1:48:24 a note of what the program's ultimate goal should be, as if you were explaining it to
1:48:28 a friend of yours. This method really lets you plan out everything that needs to happen
1:48:32 in your program in order for it to run smoothly. It also ensures you don't forget about a
1:48:37 piece of an algorithm, or a certain function that you need to write in afterwards.
1:48:42 And the final pseudocode strategy that I'd like to talk about today is writing out the
1:48:47 main features you want the user to have when using your program, and what functions or
1:48:51 smaller programs you're going to need to complete those features. Let's do another
1:48:55 example, say you're making a banking interface and on start-up, you want the user to initially
1:49:00 have 2 different options. They can set up a new account or log into an existing account.
1:49:06 From there, if they log into their account you then want them to have the functionality
1:49:10 to withdraw money, deposit money, take out a loan, or pay back a loan. If they decide
1:49:16 to set up a new account, you want them to be able to create an account, store their
1:49:19 information in a database, and then access all of the features that a returning member
1:49:24 would have. This may look very similar to the flowchart, the only difference being this
1:49:29 is abstracted one level higher, over an entire program rather than just a single function.
1:49:35 If you really wanted to, you could also create a flowchart that would go through the functionality
1:49:40 of all 4 methods described above. Setting up the hierarchy like seen on your screen
1:49:45 now makes it clear to see every function and interface you're going to have to make.
1:49:50 This prevents you from having to try and shoehorn a function or feature into an almost finished
1:49:54 program at the last second is not a very fun experience in the slightest.
1:49:59 So there you have it, 3 pseudocode strategies you can use to plan out your code before you
1:50:04 even start writing any. The flowchart method, which is good for thinking through the flow
1:50:08 of a certain function. The write-up method, which is good for getting the general idea
1:50:12 down for a program, or the functionality planning method, good for listing out the functions
1:50:17 of a certain program. You can use none of them, all of them, a mix of them, or even
1:50:22 disregard these and find or create your own. The main goal here is to drastically minimize
1:50:28 the amount of errors that occur during your programming and relieve a lot of stress on
1:50:32 your head. The importance of pseudocode cannot be stressed enough, and if you don't believe
1:50:37 me, I urge you to try and complete a large project without it.
1:50:42 Ok, so if you've watched the series up until this point, you have gotten a pretty good
1:50:46 understanding of many aspects of programming, and also how to plan out your programs. الآن
1:50:51 it's time to go out into the real world, and write some actual code.
1:50:56 But what kind of program? I can hear you asking أنا. And the answer is truly whatever you want,
1:51:01 really. As I'm sure you know by now, you can program just about anything that you have
1:51:05 on your mind, anything from simple games to complex software. We've equipped you with
1:51:10 the basics that are going to be used in pretty much any program you do decide to write. لكن
1:51:15 that doesn't mean every programming language is perfect for every application. Each language
1:51:20 has its own strengths and weaknesses, and choosing the right one is very important for
1:51:25 making it easier, or sometimes even just possible, for you to program what you want. اذن هذا
1:51:30 what we are going to talk about now: choosing the best language for what you want to accomplish.
1:51:34 Now, we talked earlier about low level versus high level programming languages. في حال
1:51:40 you forgot, let's do a quick refresher. Higher level programming languages have a
1:51:45 high level of abstraction from machine language, that series of 0's and 1's from way back
1:51:49 when, while lower level programming languages have a low level of abstraction from machine
1:51:55 language. For example, block programming where you drag and drop programming statements together
1:52:00 like 2d legos would be a high level language, as it does not take a high level of understanding
1:52:05 of the inner workings of a computer to program عليه. The theoretical highest level of a programming
1:52:11 language would be if I could just write down what I wanted the computer to do in simple
1:52:15 english and it would just work. But, sadly, that doesn't exist yet. On the other side
1:52:21 of the spectrum, the lowest level programming language would be just feeding 0's and 1's
1:52:26 into the computer at supersonic speed, which would be almost impossible and extremely absurd.
1:52:32 So, how do you choose what type of language is best for your needs? Well, it depends what
1:52:37 you are trying to do, as sometimes you need very specialized languages to get done what
1:52:41 انت تريد. The world of computer science is vast and contains many fields, so trying to
1:52:47 cover everything in one language would be غير ممكن. This has led to the creation of
1:52:51 thousands of different programming languages each designed for a specific task. الآن
1:52:56 though, we'll cover some of the most popular languages and their uses.
1:53:01 Now, if you are trying to design a website, and delve into that career path, using HTML
1:53:05 and CSS is probably your best bet. HTML is a markup language that is designed for writing
1:53:10 the content of a website, while CSS is great for designing the style of the website. أنت
1:53:16 interact with HTML code every day and you can even see it right now if you right click
1:53:20 and hit inspect element, this will truly show you how complex HTML and CSS can be.
1:53:26 Maybe it would be best for you to use a scripting language. A scripting language is a language
1:53:30 that has many commands for you to use and that can also be run without needing to be
1:53:34 compiled. Scripts can be faster to write than actual programs, and tend to be easier to
1:53:39 port between operating systems allowing for cross-platform support. Scripts can also be
1:53:45 used with websites, oftentimes adding to the overall user experience of the site. اذا أنت
1:53:51 want to go into web design, this might also be a path for you to go down. Examples of
1:53:55 scripting languages are Perl, PHP, Ajax, and Javascript.
1:53:58 If you just want to make a general purpose program, you should probably use a general
1:54:03 purpose language. General purpose languages, as they sound, have a wide range of applications.
1:54:11 Usually these should be your go-to languages. Examples of general purpose languages are
1:54:16 Java, C++, and Python. They each have their own different benefits over one another. Java
1:54:22 is best at developing games and interactive web pages, Python can act as a scripting language
1:54:28 for web programming as well as writing applications and data analysis. And C++ is best for writing
1:54:34 applications and system programs. They all have a variety of packages that you can import
1:54:39 and use to achieve the functionality you need from them. While selecting the right general
1:54:43 purpose language for your big projects is very important, for most of your programs
1:54:47 any one of them will work. It really comes down to preference. Get to know each language,
1:54:52 and decide which one's syntax rules you like best and find most comfortable. اذا أنت
1:54:57 get to know one general purpose language really well and enjoy programming with it, you can
1:55:01 apply it to just about any of the programs you plan on writing. Personally, I tend to
1:55:05 use Python for most of my projects. هذا هو mostly not due to any functional difference
1:55:09 between Python and any other general purpose language, though there are a decent amount,
1:55:14 but it is mainly because I find its syntax rules most convenient and easiest to write
1:55:18 programs with. Overall, either you can consider the project you plan on doing, and research
1:55:23 and see which language boasts the most advantages for your purposes, or you can simply become
1:55:29 comfortable with a language and use it for most of the projects you decide to write.
1:55:34 We'll now be looking at our final topic of this introduction to programming mini-series.
1:55:40 You now have the knowledge of basic programming which will take you far in any language you
1:55:44 decide to learn, you know some good pre-programming pseudocode strategies to help you design your
1:55:49 code from the ground up, and you might already have a good idea as to the type of programming
1:55:53 language you might want to start with, so what's the next step? How can I learn that
1:55:57 language and what applications can it be used for? Well that's what we're going to be
1:56:02 covering now, so let's jump right into it.
1:56:05 Starting with the biggest question which is what's the next step. Well, now that you
1:56:09 might know which type of language you might be interested in, research that language and
1:56:13 find out whether or not you truly want to pursue that programming language. Most languages
1:56:18 like python or C++ will have either an official website where you can read up on, or a wikipedia
1:56:24 page which will provide you with useful information in deciding whether or not you want to pursue
1:56:28 that path. From there, the next step is to actually learn the language, which can be
1:56:33 done right here on YouTube. While we have taught you the basics of any programming language,
1:56:38 each specific language is going to expand upon the basic concepts and so watching tutorial
1:56:43 videos on a certain language is going to be very beneficial. Many websites will try to
1:56:46 get you to purchase paid courses or take classes which cost money, but you can find extremely
1:56:47 good courses here on YouTube for absolutely 0 cost to yourself. I would start with an
1:56:48 introduction series like the one you're currently watching, but for the language you
1:56:51 have chosen and work your way through that series, picking up on the syntax and rules
1:56:55 of that language until you become comfortable with it.
1:56:59 Once you do that, you come to a crossroads. You know how to program in a certain language,
1:57:04 but you may be completely clueless as to what to make in that language. Programmer's block
1:57:08 can leave you uninspired and not want to continue programming so I'd like to give you a few
1:57:13 sites to help out.
1:57:15 First is codingbat, a completely free website which has hundreds of coding challenges in
1:57:20 Java and Python to help you refine your programming skills and even learn some programming short-cuts
1:57:26 and tips. This is great if you want to get better at improving your efficiency and need
1:57:31 something to hone your skills as a developer. The next is CoderByte, which offers over 200+
1:57:37 challenges that you can complete in over 10 different languages, something that is sure
1:57:41 to help you improve. The final website I'd like to talk about is hackerRank, which not
1:57:46 only provides programming challenges to keep you on your toes, but also provides support
1:57:50 for using you programming skills to find jobs or internships, something you've probably
1:57:53 definitely thought about if you are taking programming up as a skill. These and many
1:57:55 more websites exist solely to keep you interested in code and work on refining your skills to
1:57:59 become better, you just have to find them because they're certainly out there.
1:58:00 Now if you're a teenager watching this series, I also encourage you to take the programming
1:58:04 classes in your high school. AP Computer Science Principles and AP Computer Science A are both
1:58:10 amazing courses which will help you greatly in the future, and are also incredibly informative
1:58:15 and important to colleges. Your school might also offer other classes in the field of computer
1:58:20 science, including ones on data structures, game design, and data science. Any and all
1:58:25 classes you can take to help expand your knowledge of programming and help you find your niche
1:58:30 is going to help tremendously.
1:58:33 As you can see, the world of code has now been opened up to you. These are just a few
1:58:37 examples of where you can go from here but there are many more we didn't talk about.
1:58:41 You can get into GitHub and start contributing to projects, you can work on your own projects
1:58:45 and collaborate with others, the possibilities are endless. The next step is up to you.
1:58:51 This concludes our introduction to programming mine-series, we hope you enjoyed watching
1:58:55 it as much as we enjoyed making it. اذا أنت enjoyed the series as a whole, consider subscribing
1:59:00 to our channel NullPointerException, which will be linked in the description, for more
1:59:05 content coming soon. شكرا للمشاهدة.