Sunday, May 22, 2022

Introduction to Programming and Computer Science – Full Course

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

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

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

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

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

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

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

يمكن أن يفهم صديقك غير الناطق باللغة الإنجليزية.هذا يجعل لغات البرمجة للغاية مفيدة والعمود الفقري لأي سلعة تقريبابرنامج. فكر بلغات البرمجة على أنها ليس الإنجليزية ، وليس رمز الجهاز ، ولكن في مكان مافي المنتصف. هناك العديد من لغات البرمجة المختلفةهناك أن لكل منها فريد خاص بها الاستخدامات. تعمل لغات مثل Python و Javaكلغات الأغراض العامة التي يمكن أن تؤدي مجموعة متنوعة من المهام الحسابية ، بينما RobotCأو HTML / CSS هي لغات مصممة للمزيد أغراض محددة مثل تحريك الروبوت أوبناء موقع على شبكة الإنترنت. يمكن للغات أيضا تختلف في مدى قوتها. على سبيل المثال،JavaScript هي لغة برمجة نصية مصمم للمهام الأصغر أثناء استخدام جافا أو الثعبانيمكن أن تنفذ المزيد من الضرائب الحسابية .

العمليات. نقيس قوة لغة البرمجة ،أو المستوى ، من خلال مدى تشابهه مع الجهاز كود ، سلسلة من 0 و 1 تحدثنافي وقت سابق. لغات برمجة منخفضة المستوى مثل التجميع أو C أقرب إلى الثنائيةمن لغة برمجة عالية المستوى مثل مثل Java أو python. الفكرة الأساسية هي أنه كلما انخفض المستوىمن لغة البرمجة الخاصة بك ، أكثر الخاص بك سيشبه الرمز ما يمكن للآلة تفسيرهكإرشادات. بصرف النظر عن الاختلاف الأغراض التي تفي بها كل لغة ، والاختيارعادة ما تنخفض لغة البرمجة إلى مسألة تفضيل ، كما هو الحال عادةالعديد من اللغات التي تؤدي مهام مماثلة. .

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

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

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

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

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

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

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

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

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

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

شيئا ما. يتم ذلك عن طريق إرشادوحدة التحكم للطباعة ، ثم تضمين أي شيء تريد طباعتها داخل الأقواس.على سبيل المثال ، في بايثون ، جزء من التعليمات البرمجية طباعة (“Hello World”) ستسبب رسالةقراءة “مرحبا العالم” لتظهر على وحدة التحكم. أنيق جدا. بيان الطباعة ضروري أيضًا للعرضوتفسير إخراج الكمبيوتر من برنامج. على سبيل المثال ، إذا أخبرت الكمبيوترلإجراء عملية حسابية بسيطة ، على سبيل المثال لتحديد ما هو 4 + 3 ، سيتم تشغيلهالبرنامج داخليًا وحساب الإجابة. ومع ذلك ، ما هو الغرض من الحصول علىتشغيل الكمبيوتر هذا البرنامج إذا لم تقم بذلك تكون قادرة على معرفة النتيجة؟ في حين أنمجرد إخبار الكمبيوتر بالأداء .

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

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

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

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

ضرب أو قسمة رقمين. الآن بالإضافة إلى معادلات الرياضيات الأساسية الأربعة ،تتضمن معظم لغات البرمجة إضافية عامل يعرف باسم معامل. إذا كان هذا هو الخاص بكأول مرة سمعت هذه الكلمة ، لا تقلق ، لأنه لا يتم تدريسها عادة في فصول الرياضيات.المعامل يسمح لنا بالحصول على ما تبقى عملية التقسيم. على سبيل المثال ، متىنأخذ 10 معامل 3 ، نقول بشكل أساسي الكمبيوتر لأخذ 10 ، تقسيمه على 3 ، تجاهلالجواب الفعلي وتعطينا الباقي من هذه العملية في هذه الحالة 1 ، منذ متىنقسم 10 على 3 ، والجواب 3 الباقي 1. الرقم 1 في هذه الحالة هو ما يتم طباعتهإلى وحدة التحكم. إذا لم يكن هناك ما تبقى ، نقول في حال أخذنا 50 معامل 2 ،بما أن الباقي يساوي 0 ، فستكون الوظيفة .

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

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

لهم معا في بيان الطباعة. هذهيسمى التسلسل. الاستمرار في مثال درجاتنا. إذا أردنالطباعة عبارة “انتهت اللعبة ، 4 كانت نتيجتك النهائية “، باستخدام 4 كعدد صحيحبدلاً من سلسلة ، يمكننا القيام بذلك عن طريق تقسيم البيان إلى سلسلتينوعدد صحيح مثل ذلك. اطبع (“انتهت اللعبة ،” + 4 + “كانتالنتيجة النهائية) نبدأ بالطبع ببيان مطبوع ،والتي ستختلف مرة أخرى عبر جميع اللغات. داخل بيان الطباعة نبدأ بهاطباعة السلسلة “انتهت اللعبة”. الآن هنا يأتي الجزء المهم ، من هناك ،نستخدم علامة الجمع وإضافة 4 إلى الطباعة البيان ، كما لو كنت تضيف اثنينأعداد. ثم يمكننا تكرار هذه العملية .

بعلامة + أخرى للسلسلة النهائية “كانتنتيجتك النهائية “ونحن قادرون على الطباعة من جملة بياننا بسهولة.من خلال القيام بذلك ، يمكننا بسهولة طباعة عدة أوراق سلاسل وأعداد صحيحة مختلفة فيبيان مطبوع واحد. يمكننا أيضًا الجمع بين الدروس التي لديناتعلمت حتى الآن وتفعل شيئًا مثل “اللعبة انتهى ، “+ (4 + 4) +” كانت نتيجتك النهائية “،في هذه الحالة لنقول أين لدينا لعبة الذي يمنحك النتيجة الأساسية ، ثم 4 نقاطلمهمة معينة أكملتها. هذه المظاهرة يعرض أيضًا جزءًا مهمًا آخر من البرمجة ،وهو في كثير من الأحيان للحصول على برنامجك لتكون أكثر كفاءة ، يجب عليك الجمعجوانب التعليمات البرمجية. الآن من المهم أن نلاحظ أن الكمبيوترسيأخذ كل ما تضعه بين قوسين .

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

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

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

الآن ، هناك العديد من أنواع المتغيرات المختلفةالتي يمكن للمبرمج استخدامها ، ولكننا الآن سيغطي فقط ما يسمى “بدائيالمتغيرات “، والتي تشمل الأعداد الصحيحة ، المنطقية ، يطفو ويضاعف ، وسلاسل ، وحروف. سنبدأ الحديث عن عدد صحيح.العدد الصحيح ، أو int باختصار ، هو بهذه البساطة كما يبدو: متغير يمكنه تخزينقيمة عدد صحيح. وهذا يشمل جميع الأعداد الصحيحة من -2،147،483،648 إلى 2،147،483،648. الآنلاحظ كيف قلت الأعداد الصحيحة ، المتغيرات الصحيحة لا يمكن ولن يحمل أي قيم عشرية ،لذلك ضع ذلك في الاعتبار عند استخدام المتغيرات. ثانياً ، منطقي. منطقي جدامتغير بدائي يمكنه تخزين قيمة صواب أو خطأ. المتغيرات المنطقيةيمكن أن تحمل هاتين القيمتين فقط ، وهي غاية .

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

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

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

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

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

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

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

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

مربع بعنوان “اسم القناة”. الآن لدينامتغيرين ولكن كلاهما يشير إلى نفس الشيء المحتويات ، كونها السلسلة “NullPointerException”.نقوم بذلك عادة لتوفير مساحة في الكود الخاص بنا للأشياء التي نعرف أنها ستحصل عليهانفس القيمة. يمكن تحديث المتغيرات في جميع أنحاء الخاص بكالشفرة. على سبيل المثال ، لنفترض أن لديك “عمر” المتغير ، وداخله كان العدد الصحيح 17.ثم احتفلت بعيد ميلاد وأردت لتحديث عمرك. كل ما عليك القيام به هومرجع المتغير ، وجعله يساوي whatever new integer you want the variableto hold, in this case 18. This would be the same as having a box labeled age, with a sheetof paper reading 17 inside of it, and then taking that piece of paper out, erasing 17,replacing it with 18, and then placing it .

Back into the box. Doing this, we are ableto easily update the contents of our variables throughout the code as things dynamicallyshift. As another example, if you were making an RPG, your character will likely have statssuch as attack, defense, mana, etc. As the game progressed you could continuously updatethe variables so that the player could get more powerful the further along that theywent through the game, and you wouldn't have to create new variables. You would justsimply need to keep grabbing that box from your storage facility, erasing and replacingthe numbers on the piece of paper, and then continue along with your code. Just keep inmind that these variables are nothing more than places in memory in which a certain valueis stored, so we can easily update the numbers, .

And their place will remain constant. بعدa code has run its course, the place in memory is deleted until you run the code again andthe program dedicates space for the variable مرة أخرى. Each time you run the code, you'remaking new boxes in your storage facility, and at the end of your code, you destroy themall to make room for new boxes next time. Another cool thing you can do with variablesis add them, subtract them, multiply them, divide them, and even modulus them. الآن هذاmostly only works for integer variables as multiplying and dividing strings doesn'tmake too much sense. But if you were making a calculator app and you stored the firstnumber the user entered as num1, and the second as num2. You could then multiply num1 andnum2 together, and either print them, or store .

Them in a new variable entitled result. ثم،each time you run the program, the user could input new numbers into the num1 and num2 variables,and they would simply be set to those new integers and return the result that correspondsto those specific numbers. This allows for you to keep easy track of which numbers arewhich and what's going on in your program which is extremely useful. Also, while youcannot subtract, multiply, divide, or take the modulus of strings, you are able to addمعهم. Let's say you had a string Str1 with the contents “Hello “ and a Str2 withthe contents “there”. You could add Str1 and Str2 to create a string that had the contents“Hello there”, either storing it in a third variable or printing it out to the console. .

The last topic we'll be covering on thetopic of variables is the naming conventions of a variable, which albeit may seem odd,but it's extremely important when trying to read your code so we will be covering it now.Now, variables have to be one continuous string, and so if you wanted to make a variable thatstored the player score, you'd have to find some way to combine the words player and score,since you can't have the phrase “player score” be the name of a variable. All programmershave their own personal preference when it comes to naming variables, but the one wewill be using on this lecture is called CamelCase, which is the process of not capitalizing thefirst word, but capitalizing every word that follows it. Going back to the player scoreexample, using the camelCase method, the variable .

Would be called playerScore. This allows usto easily identify each word and becomes really useful for long variable names like thePlayersScoreBeforeFinalBoss”,whereas if we just type it out without capitalization, it would be really confusing. This will helpa ton when you start to find bugs in your code and need to quickly scan your programto figure out whats wrong, and adds to the overall readability of the program. آخرprogrammers might use different naming conventions like using underscores to separate the wordsin a phrase, but for now we'll be sticking with camelCase. Next, we'll be moving on to conditionalstatements, which at their core, are statements that change the path of our code dependingon certain conditions. For the sake of keeping .

Things simple, for this section, red lineswill connote that our code will NOT be following that specific path, and green lines will meanthat our code IS following that path. The main type of conditional statement thatprogrammers use is the if statement, and this will show up countless amounts of times inany program you write. It is as simple as it sounds: if some condition is true, andusually the condition will be enclosed by braces, then carry out the instructions locatedwithin the if statement's brackets. Else, do another thing.Now, brackets are used in most programming languages to indicate a segment of code whichwill run. It works like this, if the condition in parentheses is true, then all of the codecontained within the brackets will run, and .

If the condition in the parenthesis is NOTtrue, then it will skip over all of the statements within the brackets. A quick note is thatwhile this is the case with most programming languages, some; like Python, use colons andwhite space to determine where a piece of code starts and ends, but for the sake ofthis series, we'll be using curly braces. Now, the condition within the parenthesiscan take on thousands of different forms such as if the value the string variable Name isequal to “Steven” or if the player's score, stored in an int variable, is greater than5, the list goes on and on. Each of these statements is evaluated as a boolean, whichyou will remember from when we talked about variables is either true or false. If theboolean is true, we run the code inside the .

Curly braces, if it's not, we pretend everythinginside the curly braces never existed and move on with our code. The if statement comes with two more additionalstatements that can go with it: else if and آخر. Else if is a conditional statement useddirectly after an if statement, and carries out mainly the same function as an if statement.However, the else if statement will only be evaluated if the preceding if (or else if)statement is bypassed due to its condition being false. So we would run through it likeso, if something is true, we would run the code inside of that statement's curly braces.Else, if that something is not true, BUT another statement inside of parentheses is true, wewould then run THAT code segment. And if neither .

Of them are true, we would skip both segmentsof code and move on in our program. This is a hard concept to wrap heads aroundso let's do an example. If we had a program that evaluated the if statement if (age = 10),we could then have a statement under that which stated else if (age = 12). Now, if theage variable was 10, which we can see from the example it is, then the code immediatelyfollowing that conditional statement in the brackets would run. The else if statementwe made would not even be tested since we know it is going to be false, and thus theprint statement inside of THAT conditional statement's brackets will be ignored, andthe code will move on to the rest of the program. Now, for example, let's say we changed theage variable to be 12 instead of 10. Now, .

Instead of the first conditional statementbeing, true, it actually evaluates as false, since age no longer equals 10. So what wedo now, is first skip over the print statement which prints out that the age is 10, sinceit's not. And now we evaluate the else if بيان. We check if age is equal to 12,which again it does, and so now we run all the code inside of that conditional statementbefore finally moving on to the rest of the program. So as a review, we check the initial if statement,if it's good we run all code within that if statement's curly brackets and move onwith our program, if the initial if statement is NOT true, we then move on to any else ifstatement's and evaluate if THOSE conditional .

Statements are true. We can have as many elseif statements as we want, although this could lead to clutter amongst your code so we'lltalk about some alternatives later on to help this out. Now that takes care of the if-elsestatement, so now we'll move on to the else بيان. The else statement once again comes afteran if or an else if statement, and will carry out its instructions no matter what, as longas the preceding statement/statements are evaluated as false. If we went back to ourprevious program, we could add an else statement which would only have the code in its bracketsrun if the age variable wasn't “10” or “12”. This would catch all cases ofthe program that didn't fit our parameters. .

It's good practice to ALWAYS have an elsestatement at the end of your conditional statements to catch any weird cases that may come upin your program. Now remember back to the fact that we canhave thousands of else if statements, after a while that can get pretty cluttered, andso another very useful conditional statement which helps circumnavigate this problem isthe switch statement. A switch statement is functionally similar to many if and else ifstatements together. You write a switch statement in the form of switch (variable), and thenbelow that you write how many cases that the variable could be. For instance, if we wroteswitch(var), then under it we could write out 5 cases that the variable var could be,and then the instructions listed under that .

Case to be carried out if the var variableis equal to that case. Now switch statements are different sinceinstead of using brackets, they use a colon to signify the start of a set of instructions,and a break statement to end it. This is very useful because you are able to essentiallyuse many if and else if statements without having to write nearly as much. In switchstatements, you just always have to remember to include a default case at the bottom ofthe expression to denote any and all cases that don't meet the above requirements.This simply catches all of the inputs that don't fit within the programs main cases.It's very similar to an else case at the end of an if-else chain. .

Now, why are these statements so useful? Well,many times, programmers want their programs to function differently depending on differentconditions. For instance, a program could function differently depending on the informationthat the user inputs, such as allowing a user to use a program or not use a program if theyare above or below 18 years old respectively. Or in say a video game, if a user's experiencelevel is above a certain threshold we might want to give them harder opponents to battle.Another example could be a program which changes the color scheme depending on the time ofيوم. Or even more simply, if a user presses a button that is meant to move on to anotherscreen in an app, the programmer would only want the app to change screens if the userclicks that button. A program without conditional .

Statements would do the same thing every time,and would be very primitive compared to one that can change depending on its conditions. So now that we know how to make and use variables,how to compare them, and what we can do with those comparisons, let's move on to anotherfoundational concept of computer science: arrays. Now we've already talked about variables,and how great they are for storing singular bits information for making our code moresimplistic, but one of the biggest drawbacks that come with variables is their inabilityto hold more than one piece of differing information. For example, let's say you're making anapp which allows users to create a grocery .

قائمة. Well there's no real easy way to createlists using variables, because it's not like you can have one variable store the namesof 7 or 8 different food items. تذكر، we can only put one piece of paper in ourcardboard box; no more. And besides, even if you were to add multiple items to one stringvariable, you still would have a lot of trouble doing simple tasks you might want from a listlike searching through it or splitting it or even deleting items from the list whenyou're done with them. This is the problem that using arrays solves for us. An array is, as you may have guessed by now,a list. You can have an array of integers, an array of strings, and even an array ofother arrays which is something we'll cover .

In a minute. Programmers use arrays when theywant to store a lot of variables containing information that is all related to each other,such as a grocery list or a high score list in a game. Think of arrays as a column inexcel or google sheets. You have the title at the top and then below it are a bunch ofbits of information which all relate to the title. Arrays are super useful when programmerswant to store a lot of information that can be easily searched through because programmershave developed methods of breaking down and using arrays to find specific informationin arrays full of thousands of different variables. As an example to show just how useful arraysare, let's say you're a startup company that owns an app that has 100,000 users. كلtime a user wants to create a new account, .

They input the username they want and thenyour program will have to check to make sure the account name hasn't already been taken.Doing this requires you to search through the information of all 100,000 of your usersto see if that username has an account with your service. An array would be able to containall of this information and make it easy to search through and find out if the accountname has been taken with little to no delay. Now the single most important thing to noteabout arrays is how you reference each element of the array within them. Let's create abasic array called numbers, and inside of it put the digits 1-10. Now when we want torefer to each cell in this array, we call upon its “index”. An index is just a fancyway of saying that numbers are placed within .

The array. Now you would think that the firstinteger in this array would be the first index, the second would be the second index and soon, but that's not the case. In computer science, programming languages refer to thefirst cell as the 0th element in the array. This means that if we were talking about ourarray of numbers we just made, the number 4 would actually be in the 3rd index, 5 wouldbe in the 4th and so on, so instead of starting our count from 1, we start from 0. It'sextremely weird and confusing but it's one of those programming quirks you are goingto have to memorize and commit to memory. If you were to not follow this nomenclatureand you refer to the last element in this array as the 10th, you get what is referredto as an “out of bounds” error, since .

You are trying to reference the 10th element,but there is no 10th element. What you're actually trying to do is reference the 9th. Another extremely important thing to noteabout arrays has to do with their size. متى you initialize an array, you can do it eitherone of two ways. You can either populate it with the elements that you want containedin the array right then and there, creating and filling the array at the same time, oryou can define how many elements you want in the array-essentially the arrays size-and then populate it with elements later. This is because when we initialize an array,it creates a space in memory that has a size of exactly what you give it, no more no less.This is great for when we want to access elements .

In the array because we can do so instantaneously,but the one downside is that we can't increase the size of the array later on, all arraysizes are final. Think of it like setting up a bookshelf with books. By populating abookshelf with a certain number of books and then moving on and filling the next shelfwith different books. We have no way to go BACK and add books to that first shelf withoutshifting everything. Once we decide how much space to dedicate space for an array in thiscase, there's no way to ADD more space. Once again because this is extremely importantto remember, this means that once an array has been defined, there is NO WAY to changethe size of it. If you have an array titled “Names” with a size of 8, and you tryto add another name to the array you will .

Receive an error, so be careful when messingaround with array sizes. Of course, you can always go back at the start of the code whenyou initially MAKE the array and allocate more space to it if you find out you needmore space to hold items, but once it's defined, you CANNOT change its size. Another small thing I want to touch upon reallyquickly is that when you initialize an array, you must determine which type of array itis right then and there. For example you have to specifically say it will be an array ofstrings or integers when defining it, and also you're not allowed to mix and match,meaning you can't have an array full of integers with a few strings and some doublesthrown into the mix. They have to be all the .

Same type. Now the last thing we're going to coveron arrays is a little funky, and that is the practice of putting arrays inside of arrays.If you make an array of arrays it's referred to as a 2D, or 2 dimensional array. يفكرof these as matrices if any of you have taken algebra classes. Now If you haven't, thinkback to our google sheets example but instead of just columns, we would add rows as well.So now, each element in our array wouldn't simply be just a String variable or an Integervariable, but an entirely new array with its own set of values and elements. The way we index these is mostly the same,except we would have 2 numbers to index instead .

Of 1. We start with the row and then the column.So a number in the position (0,2) would be in the first row three columns down, in thiscase the name Clint. A number in the position (1,1) would be two rows down and 2 columnsacross, in this case the name Chris. You get the idea. Now you can also make 3-dimensionalarrays by putting an array inside an array inside an array, but that's a little abovewhat we're going to be covering so I'm gonna cut it off there. Next up we're going to be talking aboutloops, so what exactly are loops? Next up we're going to be talking aboutloops, so what exactly are loops? Next up we're going to be talking aboutloops, so what exactly are loops? .

Next up we're going to be talking aboutloops, so what exactly are loops? Next up we're going to be talking aboutloops, so what exactly are loops? Well as you could probably tell by that statementright there, a programming loop is a statement that is used to run certain instructions repeatedly,just like how the opening statement of this topic was repeated 5 times. Loops are veryuseful for a variety of reasons. على سبيل المثال، imagine you want to print something 15 times.Sure, you could just copy and paste the print statement 15 times. But this is really annoyingto have to do, and becomes even more unrealistic when that number goes up to, say, 100 or so.Now what if instead of rewriting the same instructions over and over again, you couldsimply place the print statement inside of .

A loop, and it will occur as many times asyou would like, that's the power of loops baby. With loops we're able to repeat partsof code multiple times. Now there are three different types of loops that we will be discussingاليوم. And up first is the for loop. A for loop is very useful for situations describedabove, where you would like to carry out a certain set of instructions numerous times.The syntax for a for loop varies depending on the language, however it usually consistsof three parts. An integer value, a condition which the integer value must meet in orderto exit the loop, and an operation to modify the integer value after the instructions insideof the loop are completed. Each time the for loop runs, the operation you set will be performedon the integer, and as long as that integer .

Still meets the condition you set, usuallybeing greater than or less than a constant value, the for loop will continue to run. Eventually, when the integer has been modifiedby either increasing or decreasing it to the point where it no longer meets the condition,the for loop will terminate and the code will continue to run. For example, let's sayour integer value was i and we set it equal to 0, then we set the conditional statementas i being less than 3, so basically we're saying that as long as i – the variable wejust created – is less than 3, continue running the instructions contained within the loop.Finally, we make the operation i + +, meaning each time the loop runs we will increase itby one, and inside the loop let's just put .

A simple print statement. Now let's run through the loop. We startwith i = 0, 0 is less then 3 so we enter the loop and print out Hello World. Now that theinstructions are done we add 1 to i making it 1. Moving on, 1 in less than 3 again, sowe once again enter the loop and print out Hello World. Again, we add 1 to i, makingit 2 now. 2 is still less than 3 so we enter the loop again and print out hello world.Finally, we add 1 to i once again and it becomes ثلاثة. 3 is not less than 3 though, it isequal to 3, and so we don't enter the loop and it terminates, moving on to the next segmentof code. This is a simple example, but you can extrapolate it across programming to fitاحتياجاتك. .

Now when using a for loop you have to makesure to set up a condition that, given the initial integer value and the operation, willat some point not be met, to avoid creating an infinite loop and crashing your program.An infinite loop occurs when you give a for loop a condition which will always be metgiven the parameters of the program, and so the software crashes. For example, a for loopbeginning at 10 and checking if i is ever less than 0, and then adding 1 to i at theend of the loop will never terminate, since i will just increase infinitely. After the for loop is the very similar foreach loop. A for each loop (or a for-in-list loop, in python) is used for iterating througharrays or lists. Essentially the loop will .

Go through each element in the array and carryout some set of instructions for each value. If you would like to read all of the elementsin an array and compare them to some value, or perform some operation on them, a for eachloop is extremely useful. So for example, we could have a for each loop which iteratedacross an array and simply printed out the value of each array location. Next up, we have the while loop. A while loopwill continually carry out its instructions while a conditional statement given to itis true. This can be as long as a certain variable is true, as long as a number is lessthan another number, or while a value is still equal to another value. While loops are differentthan for loops in that the loop is not contained .

Within one statement, but stretched out andwill continue to run so long as its condition is true. Like a for loop, you can make the conditionsuch that it will eventually return false and exit the loop, however while loops willnot crash your computer should you create an infinite loop. In fact, it is very commonfor while loops to run infinitely, as, for certain programs, you would like the programto continually be iterated through instead of running once, all the way through untilyou exit out of the program. When programming a game, for instance, a whileloop would be used to iterate through your code, continually refreshing the screen asthe game runs. From there you could perform .

Operations on the screen to make the gameplayable. Creating an infinite while loop would simply be done using the syntax while(true),as the condition true will always be evaluated as true. Finally, I'd quickly like to cover an extensionof the while loop, the do-while loop. Do-while loops are very similar to while loops, exceptthey will carry out their instructions at least once, even if the condition is false,and then will carry on like a basic while loop. Essentially, the conditions inside theloop will run AT LEAST once, and then if the condition is still met they will run againand function as a normal while loop. As you can see, loops and their many varietieshave some extremely useful functions. Using .

Them, you are able to perform an operationmany times in a row, you can iterate through arrays and lists, and overall decrease theclutter of your code. Next up, we're going to take a break fromlearning about common programming statements, and dive into what happens when the code wewrite doesn't work. More specifically, we'll be covering the different types of errorsthat can occur when you're programming, and what causes them. Now when you're writing code, you have tounderstand that things aren't always going to go the way you expected them, and sometimesthe program doesn't always work as you had intended it to. We programmers call theseerrors and while annoying, they are always .

Going to come up in computer science and soit's best to learn what they are and how to deal with them. Often referred to as “bugs”,errors in scripting languages can be narrowed down to one of three “types”: syntax,runtime, and logic, all three of which we will be covering in today's video. To kick things off, let's talk about syntaxerrors. These are usually the easiest of the 3 to solve since they are oftentimes somethingthat can be fixed within seconds. If you remember back to earlier in the video when we talkedabout syntax and programming rules, we said that if you were to break the programmingrules, or syntax, that it would result in an error. Well that's what syntax errorsare, parts in your program where you fail .

To meet the programming rules and so the computerdoesn't know how to interpret your code. This can be anything, from forgetting a semicolonat the end of a statement in java, accidentally defining a variable with two words insteadof one, or even just misspelling the word String when you're trying to define a stringvariable. Lucky for you guys, these errors are extremely easy to fix since you just needto figure out where the error occurred and what the syntax rule you broke was. Now thinkingback to IDE's, we mentioned that IDE's are so useful because they do precisely that,they underline syntax errors and usually provide helpful hints as to how to fix them. يفكرof syntax errors as small misspellings or grammatical errors in an essay you're writing,annoying; yes, but not the most infuriating .

Things. Another useful thing about IDE'swhen it comes to syntax errors is that the program will actually restrict you from runningthe code unless all syntax errors are cleared, making them even easier to identify and fix. The second type of error we will be coveringis the runtime error. These errors don't show until you actually “run” the code,hence the name “runtime” error. Runtime errors are caused by a statement in your codethat SEEMS seems logically sound, but the computer physically has no way of computingit in a reasonable amount of time. The most common of these errors is one which we'vealready talked about; the infinite loop. مثل a refresher/example, think of an infiniteloop like this. Say you sat your friend down .

In front of the TV, put on the Office on repeat,and told him he could leave as soon as Michael made a “That's what she said” joke.Seems pretty simple right? WRONG, because instead of putting in the Office, you putin FRIENDS on blu ray. No michael, no inappropriate joke, meaning your friend would be sittingthere for the rest of his life probably confused as to why Dunder Mifflin looks so much likea coffee shop. This is essentially what happens with the computer, you give it some conditionthat it has to complete before the program can terminate; however, you give it no feasibleway to finish that task. This puts the computer in error mode and most likely will crash yourprogram, as the computer desperately tries to complete the condition you gave it. مثلa computer example, if we try to have a program .

Terminate when an integer i is no longer greaterthan 99, but i is initially 100 and only increases, the loop will never terminate and the programwill crash. To avoid these, you generally want to think through the flow of your codebefore running it -especially with loops- to make sure that all of your statements canbe completed by the computer. Carefully planning out your code before you begin writing itis an extremely useful practice, and something we'll be covering towards the later partof this video. The final type of error that we will be coveringis a logic error. This error is also pretty self-explanatory. A logic error occurs whenthe code runs smoothly without any runtime or syntax errors, but the result that youget isn't what you wanted. فمثلا، .

Let's say you had a calculator app, andyou wanted to instruct the program to add two numbers, except it multiplied them insteadbecause you used the multiplication symbol on accident. This leads the sum to be 36 insteadof 13. Nothing went wrong with the code syntax or runtime wise, the code runs just fine,it just doesn't work as you intended it to. These are often the hardest types of errorsto debug since most of the time, you'll have no idea why the code isn't working,and certainly not any idea of how to fix it. This is why it's a good idea to test yourcode incrementally, don't wait until you've been programming for an hour before testingyour application, or else you'll run into a lot of logic errors. Logic errors can beextremely frustrating and could cost you a .

Lot of time, making them a huge pain, butif you know how to effectively debug your code, you'll be just fine. Speaking of debugging your code, that bringsus straight into our next topic, which is how to debug your program. Now, let's say you have written a program.You think it's ready, and you're ready to test it. You've been working hard on this,and you're excited to see it in action. You run the program, and wait for it to runsmoothly and efficiently. Only, it doesn't عمل. You have encountered one of the threeerrors we just mentioned. You really want this code to work, but how? This is wheredebugging comes into play. .

If the code is giving you an error, then thefirst thing you should do is read the error. Oftentimes, for syntax and runtime errorsthe IDE will print an error message out to the console. See what line or lines it pointsto- since those will be the lines in which the error occurred- and see if you can understandand fix what it says the problem is. If the error isn't clear, or you've never heardof it, then try googling it, there are many websites out there such as stackoverflow whichserve as forums to ask and answer problems with code. Chances are, if you've had aproblem, someone else has had the same issue and there is likely a tested solution. عادة،when a syntax or runtime error pops up, you should be able to find a fix for it fairlyeasily; however, as I said before, the issue .

May arise from some loophole or oversightin the code you hadn't planned for beforehand. Maybe you did something as simple as multiplytwo variables instead of adding them. These are the logic errors we talked about previously.These problems usually won't have red text show up to explain to you what went wrong.You'll have to figure it out yourself. Now there are a few different strategies youcan use in order to track down and fix a logic error. First, you can use print statementsand the console in order to determine where the code is going wrong. Imagine you have a conditional statement thatwill run one segment of code if an integer x, is greater than 5, and will run anothersegment of code if not. .

If, in your program, x is supposed to be greaterthan 5 when the program reaches this conditional but for some reason the program is still printingout “X is small” you could use a print statement to help. For this problem specifically you could placesaid print statement before the branch of the conditional that would print the valueof x. Now when you run the program you know exactly what the computer is thinking. Printingout the value of x just before the if/else statement will let you know if the variablehas the value you want it to have, and if it doesn't you know that somewhere abovethat conditional something went wrong and x was set to a value you didn't want itإلى. In this case, x is equal to 2, which is .

Why x is small is being printed out. Now we know what the problem is we can trackdown where and when in the code we modify x to figure out the problem. Use print statementsto determine where your program goes wrong, and then try to track down the cause of theseissues and solve them. If you use this strategy, make sure you end up deleting the print statementsafterwards to avoid clutter in the console. The situation described above could also besolved using a breakpoint. A breakpoint pauses your program when the line you placed thebreakpoint at is reached in your program. If, say, you would like the program to runthrough a certain conditional and set a variable based on that conditional, but you are unsureif this actually happens correctly in your .

Code, you can place a breakpoint inside theconditional path you want to run. Upon the breakpoint being reached, the programwill pause, and wait for you to continue it through a button press. This signals thatthe spot in the code where the breakpoint was placed, in this case the correct conditionalpath, has been reached by the program. أنت can then continue the program knowing thatwas or wasn't where an error in your code occurred. Breakpoints can be used in conjunctionwith print statements in order to both pause the program, and perhaps view the values ofyour variables at the moment in time to give yourself all the information you could want.You can also have multiple breakpoints to help slowly work through your program anddetermine where the error has occurred. أ .

Combination of these two strategies will helpyou easily determine where in your code you have incurred a logic error. Next, let's go over what to do if you thinkyou have tracked down the section of code that causes the problem. You may think youshould delete it, but it's likely you put it there for a reason, and you don't wantto lose that work if you don't have to. Firstly, try commenting it out. Comments areused to markup code and explain their surrounding sections, but they can also be used to debug.Anything that is designated as a comment will not be read by the program as code, and willbe skipped over. Essentially, it becomes something that is only there for YOU the programmerto read. The syntax varies from language to .

Language, but it usually involves placingsome symbols before or around the code you would like to be commented. Examples of howto comment in different languages can be seen on the screen now. Also, when you commentsomething, the IDE will grayscale the line of code, making it extremely easy to determinewhat's commented and what is not. Commenting code 'deletes' it in the computer'seyes without actually deleting it. If a problem is present before you comment a section ofcode but it is gone afterward, then that section of code is the culprit. If you comment partof a code out and there are still issues, then move onto another section until you findthe culprit. Once you do, you can tweak it until it works as intended or delete it entirelyand you will have a fully functioning program .

مرة اخري. Hurrah! Now that we've talked about what to do IFyou've encountered an error and a strategy on how to find and fix it, I'd like to talkabout some strategies you can use to AVOID errors in the first place. Firstly, backupyour code frequently. In the event of the code completely bugging out and you beingunable to fix it, you will want the ability to revert to a previous version where thecode was still working. If you save frequently enough, then you will probably not lose toomuch work. Version managers like Github or Subversion can help with this, as they backupcode to an online cloud service in which you can easily pull previous versions of the programat any point. .

Also, on top of saving, run your program frequentlyto ensure that the current version works as intended. This accomplishes two things. Firstof all, it prevents you from saving a backup that doesn't work. Secondly, if you encountera problem, it will be easier to find if you have only made a small number of changes sincethe last time you ran it and it worked, and thus you will only have to look through thenew code for problems. If you've spent 5 hours coding and hadn't run it during thattime period, it's going to be extremely likely that at some point during that 5 hourcode sesh you messed up, and it's going to be even harder to figure out where youwent wrong. Errors, while annoying and extremely frustrating, are a fundamental part of makingyou a better programmer. .

Alright, now that we've covered errors fora bit, let's hop on back to programming statements and talk about one of the mostimportant concepts in computer science, the وظيفة. Now, you may not know it, but we've actuallybeen talking about a few functions this entire سلسلة. Print statements, for loops, and evenbasic math operations are all examples of functions, which of course begs the questionof what actually defines a function. Well, a function is a segment of code that can beeasily run “calling” the function name and depending on the type of function, willdo something in return. Functions can be called numerous times, and in numerous places. Essentiallythey are like wrapping up a segment of code .

Into a nice present and giving it a name which;when called, will unwrap the present and go through the code you wrapped up. For example, the print statements we havebeen using this series allow us to print something to the console any time we want are functions.You see, we just “call” the print function and enter in what we want to be printed tothe console, and the computer does it for us. Behind the scenes, there is actually evenmore complex code that is in charge of taking your text and translating it to the consoleto be printed. The developers of almost all programming languages realize that you don'twant to program something that manually has to print something to the console throughthe use of complex programming, and so they .

Implemented the print statement to reducethe stress and complexity of code on the user, abstracting it down to a simple line of code.All of that code that is used to print something to the console is wrapped up like a presentand given to us in the form of one line, “print()”. This is actually the main theme of all functionsand the backbone of any good program. Oftentimes in your program there are going to be sectionsof code which are repeated and serve the same purpose, or equations which you want to allowdiffering inputs of. And so you can use functions in order to condense these down into singularlines of code to save both time and reduce clutter on your code. As you will see soon,functions are EXTREMELY powerful and will definitely be something you utilize all thetime in your computer science journey. .

The print statement is just one example offunctions in everyday code. There are thousands of functions that are available to you throughIDE's. However; because you won't always use all of the thousands of functions thatare open to you in a single program you have to import these functions from packages foundin the IDE, which is something we will cover لاحقا. Now, there are four main types of functionsin most programming languages, and they are separated by two defining features: whetheror not they take in arguments, and whether or not they return values. Let's start byseparating them by whether or not they take arguments, but first we have to cover whatarguments are. .

Arguments are essentially variables that wepass into the function in order to be manipulated and then either returned back to us, printedto the console, or used in another operation. Think of functions with arguments like orderingfood at a restaurant. If you walked up to your local five guys and told them you wantedto get food without supplying a type of food, they would probably look at you confused.You need to tell them what exactly you want to order so that they can give it to you.In this case getting food is the function and what you order is being passed in as theargument. Based on what you tell them, or the argument, they will do something different.You also should note that the argument can be many different things, it could be fries,burgers, soda, anything really on the menu, .

And such is the case with arguments in programming. This is essentially what happens with thecomputer, for example, the max function which takes two integers as arguments and returnsthe maximum number between the two. Now, for this function if you don't input two numbersor variables for it to compare, it's going to throw you an error just like the five guysemployee, he doesn't know what you want to eat since you didn't provide him anyarguments, and the computer doesn't know what two numbers you want it to compare andreturn since you didn't provide it with two integers. Arguments are a way for programmersto have one function that can do many different things depending on whichever variables canbe passed through. Arguments add variability .

To programming and can help diversify yourالشفرة. Thinking back to our five guys example, a restaurant that only allows one type offood to be made regardless of what you order isn't going to be very useful or diversified,but if we're able to pass in arguments and tell them what food we want, our experiencecan be heightened and more options become available, which is exactly what happens whenyou accept arguments in your functions. Now that we've talked about functions thattake in arguments, let's move on to functions which do not take in arguments, because functionscan also be created and used without taking in arguments and still be incredibly useful.For example, let's say you were making a text based RPG game and one of the optionsyou give your player is the ability to view .

Their stats at various points throughout theلعبه. Now every time you come upon an option and they choose the “View Stats” button,you don't want to have to type out 6 different print statements for every statistic theymay have, your code would get cluttered and messy very quickly. Instead, what you coulddo is package the 6 different print statements in a simple function called printStats().You don't need to pass any arguments into the functions since the function will do thesame thing no matter what the statistics on the player are. Now, everytime the user wantsto view their stats, you simply call the printStats() function and voila, the user's stats areprinted for them to view. This allows you to save a lot of time writing out code, butalso a lot of space which is extremely important .

When your programs begin getting into hundredsand thousands of lines and you want to easily search through it. Okay, now that we've separated functionsinto those that take arguments and those that do not, let's again split these up intothose that return values and those that don't. Now the thing you have to understand is thatwhen you're making your own functions, which is something we will be covering soon, youhave to choose what your function will return, if anything at all. Functions are able toreturn values back to the user whether they be String variables, integer variables, oreven arrays. Now the thing to note about returning values is that calling the function alonewon't do anything. You have to return the .

Value into something. As an example, the Maxfunction we talked about previously would return an integer, but in order to do somethingwith it we would have to either set a new integer variable equal to the result of thatMax function, or we can print out the result of a function, which in this case would justprint out the maximum value between the two integers. Using functions which return valuesdon't do much on their own, you have to pair it with something in order to gain useout of it. Let's do another example, let's say youhad created a function which took in two string variables as arguments, combined them usingthat fancy String math we talked about earlier, and then returned them as a single string.This combineString function could then be .

Used to create new String variables sincewhat it is returning is technically a string. The variable would simply be set to whateveris returned from the combineString. The last type of function is one that doesnot return anything, and these are known as “void” functions. Oftentimes these arelike the printStats function we created earlier, simply used to condense large amounts of printstatements that appear often in your code. These cannot be set to variables since theydon't return anything and just get the code within them run through. So there you have it, the 4 types of functions.Ones that take in arguments and return things, ones that take in arguments and don't returnsomething, ones that don't take in arguments .

But still return values, and the ones thattake in arguments and don't return anything. Each of these 4 types of functions are usefuland unique in their own way and you will probably find yourself using them all throughout yourprogramming journey, so get used to the different types of functions and know how to make themost of them, as they are all extremely powerful. Finally, I'd like to talk about one of themajor benefits of functions, which is that it makes it super useful to make large changesto your code without having to go through the entire program. Each function call isjust a copy of that function's original code, and so it's very easy to make changes tothe function and have it translate to across your code. Let's go back to our printStats()function and say that you wanted to go back .

And add in a new stat that the player canlevel up through experience in the game. Without functions, you would have to go back intoyour code, find every instance that you had printed out the users stats, and create anotherprint statement to display the new statistic. However, if you had created a printStats()function like we did a little while ago, all you would need to do is find where you definedthat function and add in a print statement which displays the new statistic and you'redone, bam. Now, every place which had called the printStats function previously will nowalso print the new statistic as well. أنت can see how powerful functions can be if usedproperly, and we haven't even scratched the surface yet. .

Now, up next we're going to cover how wecan import other people's functions that they've written and use them in our code. Now before we get technical, close your eyesand imagine you are trying to build a house. Sure, you could grow your own trees, chopdown your own wood, make your own tools and nails, and build it up from scratch. لكن لماذاdo that, when you can simply go to your local Home Depot and buy these materials that othershave already made ready for you. هذا the main idea behind importing functions intoyour code. Importing functions allows you to gain access to libraries of functions thatother people have already made for you. هذه is just as useful as it sounds. يوجدso many functions that are super useful for .

Any given program that it would take you foreverto write them all yourself. Luckily, other people have already done most of this foryou. In each programming language, you are ableto use an import statement to import libraries of functions into your program that you canuse as you write it. A library is simply a collection of functionsthat all have the same theme. It may be a math library, a data analysis library, a librarywhich translates text, or anything that you can think of really. There is such a varietyof libraries for any given language that most functions you require that are not hyper-specificto your program can likely be found in some مكتبة. In fact, a good portion of any programmer'sjob is looking online for packages which can .

Make his or her job easier instead of handwritingالمهام. Now, I can hear you saying, “Wow, that's sick, how do I do it?” Well, it'squite simple: an import statement. In most languages, an import statement consistsof 3 parts. The library you would like to import from, the package you would like toimport from that library, and then which class from that package you would like to use. إلى عن علىexample, we could load up the Java library, and from there import the util package, shortfor utilities, and then from that utilities package import the scanner class, a classwhich allows us to read information from the user. A package is simply a smaller sect offunctions and methods to help differentiate between the thousands of methods containedin a library, and class is even more specialized .

Than that. Now if you don't know what specific classesyou're going to want to pull methods from, you can use a star * to import all classeswithin the package you'd like. ومع ذلك، it can be beneficial to be more specific,and only import the classes you would like, as it helps with efficiency of the programin the long run. For instance, in python, the syntax to import a library is import followedby the library name. However, importing an entire library is more computationally taxingthan importing specific functions from a library. Imagine you would only be using the factorialfunction from the python math library. It would be a waste of computing power toimport the entire library, and would increase .

The load time for your program. For smallerprograms, this isn't a big deal, but it really starts to add up when dealing withlarger projects. Therefore, you would instead use “from math import factorial” or thejava equivalent “import java.math.factorial”, and now have access to that one math commandonly. This limits the functions that you can use, however it saves programming runtime.If you decide you want to use another function that you hadn't planned for, you can alwaysgo back and import that too. Many times, if you try to use a function from a common packageand you have not yet imported it yet, the IDE will prompt you to do so. If you're trying to figure out which librariesyou want to import, think of the functions .

You're going to need in your program. Performa simple google search, and you will probably run into a package or library that alreadyexists in your IDE that you can use. و إذا you can't, there are ways to download andimport additional projects to fit your needs. But if after all of that you still can'tfind a library that contains the function you are looking for? Well that's a perfectsegway into what we're going to talk about next, which is the basic structure for writingyour own functions. So at this point we've talked about bothwhat functions are and how we can get some very useful functions by importing functionsthrough packages. But there are definitely going to be moments in your programming journeywhere you're going to want to make your .

Own functions because you want to make onespecific to your program and code. لحسن الحظ ، making your own functions is extremely simple,there are just some basic rules I want to cover. Now while we've previously used makingfunctions as an example for other topics such as the playerStats function from a littlebit ago, they were extremely abstract and didn't go in depth into what is needed foran actual function to operate. حتى الآن we're going to be covering a skeletal systemof everything that needs to be included in a function to get it to work. Now think back to the 4 different types offunctions that we talked about previously. Functions that do and don't return valuesand functions that both do and don't take .

In arguments. For creating your own functions,we're just going to go down the list and talk about how to approach creating them,starting with the most basic of the bunch, one which takes no arguments and returns novalues, but before we start that, there are a few small things I want to note about functionnaming conventions. The variable naming conventions we talked about previously also translateover to function names. So you can't have two word functions and you can't use specialcharacters like periods or commas. Generally you're going to want to follow the samecamelCase style which we talked about in the variables video. Alright, so in general for making functions,each language differentiates how you tell .

The computer that it's a function. In javayou have to define the functions scope, which is something you don't really need to knowunless you're going to become more invested in java, but basically it tells the computerwhich parts of code can use the function and which type can't. For this series all ofour functions are going to be public. From there you then determine which type of functionit is, so in this case since it won't be returning any variables we'll just put voidto signify this type of function will not be returning anything. Finally, you put thefunction name after those two identifiers along with a set of parentheses after it likeوبالتالي. The parenthesis are where your arguments would go if you were making a function thattook in arguments, but since for our first .

Type of function we're not incorporatingarguments into this function, let's just leave that blank. All of that is just for Java;Python on the other hand all you do is put def, short for define, and then the functionname with a set of parenthesis. So as you can see, each language is going to be different,but the main thing we want to remember is to always add parentheses. From there, wejust type what we want our void function to do within the confines of the function andthen close off the loop and we're done, easy peasy. In Java, the confines of the loopwould be whatever is contained within the curly brackets, and in python it would beuntil you are no longer indented. At its core, this is the most primitive type of functionwe've just made. Something which takes in .

No arguments and returns no values, quitesimilar to the printStats function from earlier على. Moving on to the next type of function, creatinga void function that takes in arguments. الآن this process is going to seem very similarto the previous except for one small adjustment. Remember the parenthesis that I mentionedlike 30 seconds ago, well we put any variables we want the user to pass into the functioninto these parenthesis, and then when we “call” that specific function, it will be requiredto have those variables passed into it. إلى عن على example, in Java, let's make a functionthat takes in 2 numbers and prints out the product of those numbers. We start with thepublic void plus name of function setup since .

Again, we won't be returning any values.And now comes the new part. Inside the parenthesis, you define which type of variables you wantto pass in as arguments, in this case an integer, and then a name for that variable. This nameis what you will use to refer to the integer the user passed in. For this example let'sjust call it num1. Then if we want to add another argument, we simply add a comma inbetween the two and we can make another integer variable num2 to hold the second number. نحنcould do this for however many variables we want to pass into the function, but for nowlet's close off the parenthesis and just print the product of num1 and num2. As youcan see, we refer to the two numbers the user will input to the function as num1 and num2. .

Now, whenever we want to call the multiplyNumbersfunction, we just have to make sure that we are putting 2 numbers in as arguments. فيthis case the number 5 becomes num1, and the number 8 becomes num2. From there we simplyrun the code and the number 40 is printed to the console. It's important to note thatyou can also mix and match variables when making arguments. So you can have someFunctionwhich takes in a char, an integer, and two strings all within one function. Pretty neatفي رأيي. The last thing I want to mention about arguments is that when you call a functionyou have to follow the variables you defined when making the function. So for our multiplyNumbersfunction you couldn't put in a string and then an int. It HAS to be two integers becausethat's what the computer is expecting to .

Be passed into the function. So now that we've gone over how to makefunctions that don't return variables, we have to cover those that do, and we'll startwith ones that don't take in arguments. Now the main difference between defining functionsthat return variables and defining ones that do not is that in some cases you have to specifythat you want this function to return an integer variable, this is most commonly used in Java,where you would replace “void” with “int” to tell the computer that you want this functionto give something back to you in the form of an integer. This works the same as if youwanted to return a string, char, or even an array. You simply replace the word after publicwith whatever variable you want to be returned .

By the function. The most important thing to remember aboutmaking functions that return variables is that no matter what path your code takes,it MUST return a variable NO MATTER WHAT. ماذا يعني هذا؟ Well let's say youhad some String function in a game and inside of it there was an if statement where if theplayer score was above a 10, you returned a congratulatory message. This works fineif you print the result of this function and the player's score is above 10. But, ifthe playerScore was less than 10 then you don't enter the if statement and then youdon't have something prepared to be returned to the user and so the function is going tothrow you an error. You HAVE to have all your .

Paths covered which may seem simple, but ifyou're making a function with a switch statement in it containing high amounts of cases, thiscan get out of hand quickly. Something I like to do just to make sure this doesn't happenis put a return statement at the bottom of the function with a string or an integer sounique that I'm able to tell that the code is not running properly and can fix it. الmain point I'm trying to get across however, is always cover your exits and always havea return statement prepared for any case the user may throw at you. Another small thing to note is that you can'treturn one type of variable if you have already defined the function to return another type.For example you can't return a string in .

An integer function or vice versa. The returnstatement must always match the type of function بغض النظر. The final type of function is one that returnsvariables and also takes in arguments, and for these all you need to do is combine whatwe've learned from the previous cases. أول، you assign your arguments in between the parenthesis,making sure you have also defined what variable you want to return, and then ensure that nomatter what path the code takes that you are always returning that variable type. ذلكconcludes our discussion on functions. مثل you can probably tell, functions are an extremelyvast subject area and require a little bit of practice to fully understand, which iswhy later on we'll recommend some websites .

You can use to practice these more difficultالمواضيع. Now I'd like to switch gears a little bitand continue our discussion from earlier on arrays. Arrays, while useful, aren't theonly way to store and manipulate information. In fact, there are a multitude of differentways to store data in computer science including LinkedLists, Stacks, Queue's, Maps, Trees,and many others too. Right now; though, I'd like to talk about2 cool, wacky and zany ways to store data that we haven't previously covered: ArrayListsand dictionaries. But before we get into those, let's get a little review/reinforcementof array's. As you may remember, arrays are basicallylists of values that are stored together. .

When you initialize an array, you give ita size, and this size is fixed. You won't be able to increase the size of the array,so when you make an array, it's length is final. To access the values in an array, youreference them using an index which starts at 0. What this means is that the first itemof an array is not at position 1, it is at position 0, and it's position is commonlyreferred to as it's index location. وبالتالي، to find the nth item in an array, you wouldrefer to it as index location [n-1]. ومع ذلك، as the size of an array is fixed, you haveto be careful to not reference a position that is beyond the total size of the array,or append too many items to it, as this will return an error. We also have what are knownas two-dimensional arrays, .

Which is an array containing an array at eachof its indexes. Or, you could have an array containing arrays containing arrays containingarrays containing arrays, depending one what you're trying to do. Multidimensional arrayscan be useful in more advanced programs for organizing a wide volume of related values.If that's confusing at all, skip back to earlier for our full discussion on Array's,the time-stamp will be in the description. Now that we've reviewed array's, let'sgo over array lists. Array lists (or just lists, in Python) can be thought of as a growingarray. Earlier, we mentioned how you have to be carefulto set an appropriate size of your array and make sure to only reference and append valuessuch that you remain within the size of the .

Array. However, with array lists, this isn'tمشكلة. After you initialize an arrayList, it instinctively has a size of 10, but ifyou append a values such that the size of the arrayList goes beyond 10 elements, anarrayList will “grow” itself, meaning that the computer will allocate more memoryto the array to increase its total size so that the new values can be appended. هذهis quite useful when you don't know the exact number of values that the array willneed to store, or want the ability to store values to your heart's content, such asmaking a database with an unknown amount of user's that will sign up. There is a lot more to uncover when regardingarrayLists, but for this surface-level series, .

That is all you pretty much need to know,so let's move on to dictionaries. Now when we talk about dictionaries, we'renot referencing that thick book you probably have lying around your house which has thousandsof definitions. In computer science, dictionaries are like arrays, in that they store multiplevalues, however their values are stored very differently. Rather than being referencedby their position within the dictionary linearly, each value is tied to another value that isused to reference it, or its “key”. Because of this, we need to throw away all conceptionsof dictionaries as a linear way of looking at data, since in actuality it is much morefluid and interchanging. Basically, we say that each position in a dictionary holds akey/value pair. When referencing a value in .

A dictionary, you will use it's unique key,and the dictionary will tell you the value that is tied to it. Think of it like this,each time you add an item to your dictionary, your computer creates a handcrafted box tostore the data, and also custom-makes a jeweled key, one of a kind, no other like it in theالعالمية. This way, there is only one key that goes to the box that stores a certain bitof information. Because each key must be unique, reusing a key in a dictionary will resultin an error being thrown because having two keys that are exactly the same would confusethe computer as to what box, or bit of information, that key leads to. However, you can storethe same value in multiple key/value pairs, since the keys would all be different. .

Now like I said, dictionaries are more fluid,making them easier to organize than arrays, as everything is set up in a more logicalmanner. That is to say, it is easier to find the value you are looking for when you areusing keys rather than simply referencing their positions. Let me explain what I mean.Imagine you have a dictionary of prices at a store where the key is the name of the productand the value is the price of the item. يمكن apples cost 1 dollars, milk costs 2 dollars,and bread costs 3 dollars. You can see that in the dictionary, each key is the name ofa product, and each key corresponds to the price of each product. So to find the priceof bread, all you need to do is simply call the dictionary using the key “bread”,and the dictionary would return the value .

1. This makes it extremely easy to track valuesthrough your code since you're working with tangible values rather than numbers whichdon't mean anything to you. You can also manipulate dictionaries in manythe same ways you can manipulate arrays and array lists. You can iterate through a dictionaryand perform many operations and comparisons on the values. If you want to find the productwith the highest price, for example, you can iterate through the dictionary to find thevalue that is the highest amongst the grocery store items. Arrays, arraylists, and dictionaries are usefulin their own right, as are the mass amounts of other ways to store data, and each boastcertain advantages over one another. We already .

Covered the basics of 3, but since there areso many, we don't have time to go in-depth into each and every one of them, and so inorder to help you grasp the basics of storing information, we're now going to talk aboutone of the most important functions needed to understand arrays, which are searchingalgorithms. Now, just as there are many ways to storeinformation in computer science, there are even more ways of searching through lists.Searching algorithms at their core are ways in which we can look through a list of valuesstored in an array, say a patient name list or a high score list, and find a particularpiece of data. The goal of a searching algorithm is to simply give the algorithm a string orobject you want it to find and return the .

Index of the array that contains that stringor object as fast as possible. Now this may seem simple, but lots of software runs onthe backbone of being able to search through lists extremely quickly, making searchingalgorithms, and in particular efficient searching algorithms, an important topic to cover. Additionally,this is the main functionality that arrays are used for and is the backbone of many ofthe methods used with arrayLists as well as many other storage methods, so knowing themwill take you a very long way. Typically searching algorithms are used toreturn the index of a particular data point so that it can be used, modified, updatedor checked on. For example, if you are about to check into a hospital run on an array systemfor patients, the staff must search for your .

Name in the database and by returning theindex of where your name is, they now have a quantifiable number that they can use toeasily check you in, rent out prescriptions, schedule you for checkups, update your personalinformation, etc. without having to search through the list for your name every time. You may think that there is little differencebetween searching algorithms, since computers nowadays can perform millions of calculationsper second, but when you're a huge multi-billion dollar corporation trying to find a certaindata point in a list containing thousands or even millions of data points, small differencesin efficiency are going to make or break the user experience. Even a 1% improvement inefficiency can mean big differences in the .

Amount of time a user is waiting for a simpletask. Now before we jump into different types ofsearching algorithms, we must discern between the two states that arrays or lists can bein, either sorted or unsorted. A sorted list of information is characterized by some sortof rankable value, whether that be a patient ID, credit card number, or even by alphabeticalvalues like username's or legal names. An unsorted list is just some random assortmentof related information, not sorted by any particular order or reason. Some searchingalgorithms only work for sorted lists, usually the more efficient ones, and some work forboth sorted and unsorted lists, although these are usually less efficient. If you end uppursuing computer science further, you will .

Have to deal with both sorted and unsortedlists, so it's good to know common searching practices for both Another thing to note is that we determinethe efficiency of a searching algorithm based on both the worst case scenario and the averagenumber of items it must search. We call this Big O notation, in which each searching algorithmhas an equation which takes in the size of the array as an integer n, and will outputan worst-case scenario efficiency value that we can use to compare with other searchingalgorithms. We can then also look at how long; on average, it takes to find an element ina list. Using these two methods allows us to easily compare how efficient two algorithmsare. Alright, now that we've got some background .

On searching, let's hop right into it. The first type of search we'll be talkingabout is called a linear search and you've honestly probably used this multiple timesthroughout your life. Every time you have to search for your name on a list of peopleyou probably follow the same pattern. أنت start at the top, check to see if the firstname on the list is yours, if it is. عظيم. If not, you move on to the next name on thelist until either you find your name, or you don't in which case you leave. A linearsearch works the same way, you start with the first element in the list, compare itto the value that you're trying to find, and if they're the same you've found yourmatch and return the index of that element, .

And if not you move on to the next elementin the list until you either find the thing you're searching for or you run out of listto check. Seems pretty simple right? هذه is because linear searches are pretty badwhen it comes to efficiency, especially in the worst case scenario. If the item you'researching for in the list is the last element, you're going to have to check the entirelist of items before you find the one you're searching for. On average; however, you'regoing to get it about halfway through the قائمة. This makes the linear search O(n) worst-casescenario, since in the worst possible case it will take the entire length of the array,or n, to find the correct value. The linear search on average will return the correctindex in O(n/2) or halfway through the list. .

The linear search is great; however, sinceit can work with both sorted and unsorted lists, because of the fact that it will eventuallycover every element in the list. الأخرى search we'll cover requires the list tobe sorted which may seem like a drawback, but having a sorted list allows you to usealgorithms that are far more efficient than the linear search. So overall, the linearsearch is a good basic searching algorithm for if you have an unsorted list, but if yourlist is sorted, there are way more efficient options out there for you, such as the binarysearch which we'll be talking about now. The binary search uses a recursive processto break the data in your list down into more and more manageable bytes, taking advantageof the fact that it's sorted, in order to .

Find the item you're looking for faster.This one is much harder to wrap your head around so let's start with an example. دعوناsay you have a list of 10 names sorted alphabetically, like shown on the screen now, and you wantedto find your name within that list. In binary search you would first look for the middle-mostname, in this case the one at the 4th index. Just a quick aside, since there is no “true”middle, the computer automatically uses the next one down as the “middle” value. الآن،once you find your middle value, you first check to see if the name you're searchingfor at the index you've chosen, if it is you simply return that index, but 99.9% ofthe time it's not including right now, so let's keep going. If the value at the middleindex is NOT equal to the one you're searching .

For, you check to see if the value you'researching comes before or after the middle index. For example, if you were looking forthe name Brendan and the value at the middle index was Carl; Brendan obviously comes beforematthew alphabetically and since we know the list is sorted, what we can do now is ignorethe entire bottom half of the list and just focus on the top, since we know that if Brendanis even in the list, it's going to be in that top half. Now, we simply treat the tophalf of the list as an entirely new entity and repeat the process over again. مرة أخرى،we would find the middle-most element of this new list of names and again compare it tothe name you're trying to find. If it's the name we're trying to find, we returnthat index, but if not we compare to see if .

It comes before or after the middle index.Going back to our example, let's say the middle index of this new list is AJ. الآن،we know that Brendan comes AFTER AJ alphabetically so we can now ignore the top half of the listsince we know that Brendan is going to be in the top of our list. Now we repeat thisprocess again and again until we find the name we are looking for. So for our example,the middle index this time is Brendan, and that's what we're searching for so wefinally would return index 2. In binary search, eventually the index we compare to our searchterm will be the same and once it is, we can return the index and move on. Now if we don'tfind it, which happens after we have eliminated the entirety of the list without finding oursearch term, the algorithm will simply return .

A null value to let you know that the itemyou're searching for cannot be found in the list. The binary search is way fasterand more efficient than the linear search since we are drastically cutting down theamount of elements we have to look at, making the program run faster. In almost 99.9% ofcases in which your list is sorted, the binary search is going to return a result fasterthan the linear search, so if you have a sorted list, your best option is to go binary. مثلfor efficiency, the binary search is O(log n) for the worst case scenario which can beconfusing if you don't fully understand logarithms, but all you need to know is thatit is way more efficient than the linear search. It's average scenario is actually also O(logn) as well, which again is infinitely times .

More efficient than linear. Now, while there are other types of searchingalgorithms you can use, these two are the most common for both unsorted and sorted lists,so we will stop there for now. Up next, we're going to be covering one of the most confusingand important topics in computer science, recursion. Let's start with the most important question:what exactly does recursion mean? In programming, recursion refers to functions that repeatedlycall themselves. Meaning, that in the instructions that occur within a function, one of the instructionswill be a call to that same function you're already in.In the extremely primitive exampleon your screen now, you can see we have some .

Function which, in the confines of itself,calls itself. A recursive function will usually take into account some integer as an argument,and will use this to carry out some instructions, modifying the integer that was entered, beforecalling itself again with that new integer as its argument. To better understand these functions, let'sdiscuss the basics of how we go about programming one of these recursive functions and createone ourselves. A really good easy example of a recursive function is one which sumsall numbers from 1 to n, so let's make a recursive function that does just that. الfirst thing we need is the actual function, and we're going to make it an integer functionwhich takes in an integer n as an argument. .

The reason we do this will be explained laterbut for now let's move on to the base case. A base case is simply a definite value whichall recursive statements, the ones that are being repeatedly called as we go through thefunction, try to get towards. At the beginning of the function, we test the value that waspassed in by the argument against the base case to see if it is satisfied. Usually, thesebase cases are some requirements, like if n, as I described before, reaches a certainvalue or is equal to a certain value. It is extremely important that the base caseis set to some requirement that n will eventually meet for the same reason that it is importantto avoid infinite loop: we do not want a stack overflow error to occur. For example, if ourbase case was to stop calling the recursive .

Function when n was greater than 100, andif it is not, we call the function again but with n-1, and we started with n as 99, wewould never reach the base case and the recursive function will repeatedly call itself overand over and over again, subtracting 1 from n and hoping that somehow it will eventuallybe greater than 100 until your computer crashes, not fun. So anyways back to our recursivesum example, let's make our base case when n is less than or equal to 1. This way, wecan start at some positive integer n and subtract from it until it hits at or equal1, in which case we can exit the recursive بيان. رائع. Now, if n is not less thanor equal to 1, what we want to do is return the SUM of both n and then the returning valueof our recursiveSum method minus 1. Why do .

We add n + the function call? Well let'sactually go through the function as if we were the computer and see why. We start witha call of recursiveSum with n = 3. We know that 3 is not less than or equal to 1 so nowwe try to return a recursive sum of n (which is 3) and the returning value of recursiveSumwith an n of 2. We don't KNOW what the returning value ofrecursiveSum with an n of 2 is so we have to go through the function again, only thistime n is 2.Again n is not less than or equal to 1, and so this function will go into theelse statement and return…2 plus ANOTHER recursive statement, in this case the returningvalue of recursiveSum with an n of 1. So once again we have to go through the recursiveSumfunction to get the value that will be added .

To 2 and then returned and added to 3 andthen returned. Hang in there we're close. Now in this function, n IS less than or equalto 1 and so we return n, which is 1. Now we take that n, which is 1, and that iswhat gets added to 2 in the previous function call and then returned, so this would return3. Now this 3 is what gets added to the first function call, which is three, and so it becomesthree plus three which is 6. And FINALLY after all that time, we get 6 returned from theوظيفة. Which, if you've been following along at home, 3 + 2 + 1 is indeed 6. Nowthis may seem like a waste of time since 1 + 2 +3 is not a hard operation. But to thoseof you saying that I ask you to please give me the sum of all numbers from 1 to 3,567.الله. Now recursion is a VERY difficult .

Concept to wrap your head around, so if you'renot 100% comfortable with it at the moment, please rewatch this section of the lectureto better familiarize yourself with it. Alright cool, now that we have a little backgroundon recursion, let's talk about why it works so well. Now to understand why and how recursionworks, we must first understand what a stack يكون. A stack is a data structure that containsall of the tasks you instruct your program to complete. Based on a certain method, yourprogram will then carry out the tasks you give it. It's called a stack because if we call startanother process before the previous one completes, the process is “stacked” on top of theother one such as the animation on your screen .

Is showing now.Programs we write will follow the LIFO structure. For those unfamiliar with accounting, LIFOmeans last in first out, or the last item put on the stack will be the first one removedfrom it. Essentially, every time you ask your computer to complete a task, that task isadded to the stack, and will be the first one to be resolved. Think of it like a stackof stones, you can keep adding stones on top of your pile, but in order to get to one nearthe bottom, you first have to remove all the rocks on top of it. Now when your functioncontinually calls itself without end; without a base case, like in our infinite loop examplethen the stack will never be resolved, as items will be continually added to the stackwithout any of them ever being completed. .

In this case, the memory allocated to thestack is exceeded, and a stack overflow error occurs, resulting in your program crashing.Think of this as if you're doing chores and before you complete one chore, you getcalled to do another chore, and then before you can complete that one you get called todo another one. Since you keep stacking tasks or chores ontop of each other, the stack of tasks will never be completed and you will probably diebefore ever finishing any of your chores. This is the same logic that makes infiniteloops crash your program. Recursion works on these same principles. The initial callmakes a second call which is added to the stack, and now that one must be taken careof first, but in that one another function .

Is called which gets added to the stack, andso on, until you reach the base case in which you slowly start going back down the stack. In conclusion, recursion in general is extremelyuseful because by calling the same functions repeatedly it breaks down the problem intosmaller sections, and results in the program being more efficient. Small parts of problemsare easier to solve and less taxing to compute than the entire problem at once, and the computercan combine these small solutions into the main solution in the end. Now as we wind down our introduction to programmingseries, we want to take some time and go over some of the soft skills needed to be a successfulcomputer scientist since it's not all about .

Writing code. In fact, many professional computerscientists will tell you that the majority of their job is spent thinking about coderather than actually writing it. This is because much of programming boils down to problemsolving. How do we optimize this system, how can we make this feature for our app? ماذاtype of movement do we want for our game and how can we program it? The harsh truth is that no good program hasever been written simply from the programmer getting the prompt or idea, sitting down,hopping on an IDE, and starting to write code. There are many tasks we should go throughbeforehand in order to plan out our code so we ensure that when the time comes to program,it's a clean and easy process, and not riddled .

With mistakes and bugs. This is where pseudocodecomes into play. Think of pseudocode like this, if you wantedto take a family trip to the grand canyon, would you simply hop in your car and driveoff and figure things out later? No, because that would be ridiculous. Instead, you wouldspend some time planning out the trip, what sites or places do you want to visit? ماذاhotel reservations are you going to have to make? What kind of things are you going todo when you get there? What routes or highways are you going to take and why? كل هذهthings must be determined out before you can even think about hopping in your ford explorer.So how does this translate to pseudocode? Well, think of our family trip to the GrandCanyon as a program. Programmers use pseudocode, .

Pseudo meaning not real, and code meaning,well, code, as a means to plan out their programs before they write them, just like how we plannedour trip before going. They throw away syntax and naming conventions for variables and justfocus on what they want the program to accomplish, and how they plan on doing that. Pseudocodeis very similar to constructing an outline for a paper you're writing. You write downthe main topics of the essay and plan out your major talking points, but you don'tworry about the nitty gritty details of it all such as word choice, grammar conventions,and proper formatting. By doing this, we allow ourselves to think freely and not worry aboutstressing the small stuff. At least not yet. Alright, so now that we know WHAT pseudocodeis, let's talk about HOW we write pseudocode. .

You see, the best part about pseudocode isthat it can take the form of many different things for many different people. Each computerscientist probably has their own methodology for planning out their code, and since thereare probably hundreds of different methods of writing pseudocode that are out there,today I'd like to focus on 3 popular ones that I think you might find to be extremelyuseful. The first of these are known as flowcharts,and mainly they can be used to think through the process of a particular function. A flowchartis fundamentally a graphical representation of a function and how it might flow. Manyprogrammers do this, and lay out the conditional statements and loops they want as differentblocks in the flow chart, connected by arrows .

And charting out every path of their function.From there, it's extremely easy to create test cases and follow them throughout theflow of the function through the different blocks and arrows. For example, we could havea flowchart that goes something like this. A user enters a number, and if this numberis 8, I want the program to return True; ومع ذلك، if the number is not 8 then I want to returnfalse. It's a great way to visualize what the function's overall purpose is and alsolook for any errors that you may have missed when thinking about the function, such asa missing path. It also abstracts the programming statements up to simple blocks, making iteasier to modify or change completely. ال best part is, that when you have finishedtesting cases you can simply convert the blocks .

Into statements and you have a well-writtenfunction without any debugging. Another popular pseudocode technique thatis used often is to simply write out what you want your code to do chronologically.Don't necessarily think about what programming statements and functions you want to use,just jot down, from start to finish, what it is the program you are writing is goingto do step by step. For example, let's say you're making an app that takes in two numbersand divides them. The pseudocode for that would look a little something like this. FirstI want to prompt the user to enter a number, then I want to wait for the user to inputthe first number. After I get the first number, I want to again prompt the user to input asecond number. Once they do, I complete the .

Operation by dividing the two numbers enteredand return the result back to the user. هذه all seems like it would be common sense, butremember that oftentimes we're not going to be working with simple multiplication functions,we may be working with full-scale games, algorithms, or user interfaces with many different options.This method allows you the programmer to not get bogged down with the syntax and conventionsyou have to follow, you're simply making a note of what the program's ultimate goalshould be, as if you were explaining it to a friend of yours. This method really letsyou plan out everything that needs to happen in your program in order for it to run smoothly.It also ensures you don't forget about a piece of an algorithm, or a certain functionthat you need to write in afterwards. .

And the final pseudocode strategy that I'dlike to talk about today is writing out the main features you want the user to have whenusing your program, and what functions or smaller programs you're going to need tocomplete those features. Let's do another example, say you're making a banking interfaceand on start-up, you want the user to initially have 2 different options. They can set upa new account or log into an existing account. From there, if they log into their accountyou then want them to have the functionality to withdraw money, deposit money, take outa loan, or pay back a loan. If they decide to set up a new account, you want them tobe able to create an account, store their information in a database, and then accessall of the features that a returning member .

Would have. This may look very similar tothe flowchart, the only difference being this is abstracted one level higher, over an entireprogram rather than just a single function. If you really wanted to, you could also createa flowchart that would go through the functionality of all 4 methods described above. Settingup the hierarchy like seen on your screen now makes it clear to see every function andinterface you're going to have to make. This prevents you from having to try and shoehorna function or feature into an almost finished program at the last second is not a very funexperience in the slightest. So there you have it, 3 pseudocode strategiesyou can use to plan out your code before you even start writing any. The flowchart method,which is good for thinking through the flow .

Of a certain function. The write-up method,which is good for getting the general idea down for a program, or the functionality planningmethod, good for listing out the functions of a certain program. You can use none ofthem, all of them, a mix of them, or even disregard these and find or create your own.The main goal here is to drastically minimize the amount of errors that occur during yourprogramming and relieve a lot of stress on your head. The importance of pseudocode cannotbe stressed enough, and if you don't believe me, I urge you to try and complete a largeproject without it. Ok, so if you've watched the series up untilthis point, you have gotten a pretty good understanding of many aspects of programming,and also how to plan out your programs. الآن .

It's time to go out into the real world, andwrite some actual code. But what kind of program? I can hear you askingأنا. And the answer is truly whatever you want, really. As I'm sure you know by now, youcan program just about anything that you have on your mind, anything from simple games tocomplex software. We've equipped you with the basics that are going to be used in prettymuch any program you do decide to write. لكن that doesn't mean every programming languageis perfect for every application. Each language has its own strengths and weaknesses, andchoosing the right one is very important for making it easier, or sometimes even just possible,for you to program what you want. اذن هذا what we are going to talk about now: choosingthe best language for what you want to accomplish. .

Now, we talked earlier about low level versushigh level programming languages. في حال you forgot, let's do a quick refresher.Higher level programming languages have a high level of abstraction from machine language,that series of 0's and 1's from way back when, while lower level programming languageshave a low level of abstraction from machine language. For example, block programming whereyou drag and drop programming statements together like 2d legos would be a high level language,as it does not take a high level of understanding of the inner workings of a computer to programعليه. The theoretical highest level of a programming language would be if I could just write downwhat I wanted the computer to do in simple english and it would just work. But, sadly,that doesn't exist yet. On the other side .

Of the spectrum, the lowest level programminglanguage would be just feeding 0's and 1's into the computer at supersonic speed, whichwould be almost impossible and extremely absurd. So, how do you choose what type of languageis best for your needs? Well, it depends what you are trying to do, as sometimes you needvery specialized languages to get done what انت تريد. The world of computer science isvast and contains many fields, so trying to cover everything in one language would beغير ممكن. This has led to the creation of thousands of different programming languageseach designed for a specific task. الآن though, we'll cover some of the most popularlanguages and their uses. Now, if you are trying to design a website,and delve into that career path, using HTML .

And CSS is probably your best bet. HTML isa markup language that is designed for writing the content of a website, while CSS is greatfor designing the style of the website. أنت interact with HTML code every day and youcan even see it right now if you right click and hit inspect element, this will truly showyou how complex HTML and CSS can be. Maybe it would be best for you to use a scriptinglanguage. A scripting language is a language that has many commands for you to use andthat can also be run without needing to be compiled. Scripts can be faster to write thanactual programs, and tend to be easier to port between operating systems allowing forcross-platform support. Scripts can also be used with websites, oftentimes adding to theoverall user experience of the site. اذا أنت .

Want to go into web design, this might alsobe a path for you to go down. Examples of scripting languages are Perl, PHP, Ajax, andJavascript. If you just want to make a general purposeprogram, you should probably use a general purpose language. General purpose languages,as they sound, have a wide range of applications. Usually these should be your go-to languages.Examples of general purpose languages are Java, C++, and Python. They each have theirown different benefits over one another. Java is best at developing games and interactiveweb pages, Python can act as a scripting language for web programming as well as writing applicationsand data analysis. And C++ is best for writing applications and system programs. They allhave a variety of packages that you can import .

And use to achieve the functionality you needfrom them. While selecting the right general purpose language for your big projects isvery important, for most of your programs any one of them will work. It really comesdown to preference. Get to know each language, and decide which one's syntax rules youlike best and find most comfortable. اذا أنت get to know one general purpose language reallywell and enjoy programming with it, you can apply it to just about any of the programsyou plan on writing. Personally, I tend to use Python for most of my projects. هذا هوmostly not due to any functional difference between Python and any other general purposelanguage, though there are a decent amount, but it is mainly because I find its syntaxrules most convenient and easiest to write .

Programs with. Overall, either you can considerthe project you plan on doing, and research and see which language boasts the most advantagesfor your purposes, or you can simply become comfortable with a language and use it formost of the projects you decide to write. We'll now be looking at our final topicof this introduction to programming mini-series. You now have the knowledge of basic programmingwhich will take you far in any language you decide to learn, you know some good pre-programmingpseudocode strategies to help you design your code from the ground up, and you might alreadyhave a good idea as to the type of programming language you might want to start with, sowhat's the next step? How can I learn that language and what applications can it be usedfor? Well that's what we're going to be .

Covering now, so let's jump right into it. Starting with the biggest question which iswhat's the next step. Well, now that you might know which type of language you mightbe interested in, research that language and find out whether or not you truly want topursue that programming language. Most languages like python or C++ will have either an officialwebsite where you can read up on, or a wikipedia page which will provide you with useful informationin deciding whether or not you want to pursue that path. From there, the next step is toactually learn the language, which can be done right here on YouTube. While we havetaught you the basics of any programming language, each specific language is going to expandupon the basic concepts and so watching tutorial .

Videos on a certain language is going to bevery beneficial. Many websites will try to get you to purchase paid courses or take classeswhich cost money, but you can find extremely good courses here on YouTube for absolutely0 cost to yourself. I would start with an introduction series like the one you'recurrently watching, but for the language you have chosen and work your way through thatseries, picking up on the syntax and rules of that language until you become comfortablewith it. Once you do that, you come to a crossroads.You know how to program in a certain language, but you may be completely clueless as to whatto make in that language. Programmer's block can leave you uninspired and not want to continueprogramming so I'd like to give you a few .

Sites to help out. First is codingbat, a completely free websitewhich has hundreds of coding challenges in Java and Python to help you refine your programmingskills and even learn some programming short-cuts and tips. This is great if you want to getbetter at improving your efficiency and need something to hone your skills as a developer.The next is CoderByte, which offers over 200+ challenges that you can complete in over 10different languages, something that is sure to help you improve. The final website I'dlike to talk about is hackerRank, which not only provides programming challenges to keepyou on your toes, but also provides support for using you programming skills to find jobsor internships, something you've probably .

Definitely thought about if you are takingprogramming up as a skill. These and many more websites exist solely to keep you interestedin code and work on refining your skills to become better, you just have to find thembecause they're certainly out there. Now if you're a teenager watching this series,I also encourage you to take the programming classes in your high school. AP Computer SciencePrinciples and AP Computer Science A are both amazing courses which will help you greatlyin the future, and are also incredibly informative and important to colleges. Your school mightalso offer other classes in the field of computer science, including ones on data structures,game design, and data science. Any and all classes you can take to help expand your knowledgeof programming and help you find your niche .

Is going to help tremendously. As you can see, the world of code has nowbeen opened up to you. These are just a few examples of where you can go from here butthere are many more we didn't talk about. You can get into GitHub and start contributingto projects, you can work on your own projects and collaborate with others, the possibilitiesare endless. The next step is up to you. This concludes our introduction to programmingmine-series, we hope you enjoyed watching it as much as we enjoyed making it. اذا أنتenjoyed the series as a whole, consider subscribing to our channel NullPointerException, whichwill be linked in the description, for more content coming soon. شكرا للمشاهدة. .

RELATED ARTICLES

Most Popular