Posts

[Motivational] Computer Science in Context: What you can achieve after taking this course!

Welcome to... COMPUTER SCIENCE IN CONTEXT! Welcome to the amazing world of Computer Science! On this very moment you are embarking on a journey to one of the most amazing disciplines in our current and future world. Computation, programming and Computer science are essential in our daily lives. I hope this post will give you the context you need to visualize where you can go with what you’ll learn in this course, what you can create and how amazing it can be to learn computer science. FIRST, LET ME TELL YOU THIS:   EVERYTHING YOU LEARN IN THIS COURSE WILL BE VITAL FOR YOUR FUTURE IN COMPUTER SCIENCE. THIS COURSE TEACHES THE PRINCIPLES THAT CAN BE APPLIED TO ALL PROGRAMMING LANGUAGES, AND THE THINKING AND PROBLEM SOLVING SKILLS YOU LEARN IN THIS COURSE CAN EASILY BE TRANSFERRED TO OTHER TECHNOLOGIES. Do not give up when you can’t figure something out immediately. Instead, try to break down the problem into smaller components and a solution will soon come to your mind. Y

Introduction to the map() Function: Behind the Scenes

Image
👋 Welcome In this tutorial you will learn how to work with the built-in  map()  function. Let’s begin. 🔹 Purpose and Syntax The  map()  function applies a function that is passed as argument to every element of an iterable. 💡 Tip:  An iterable is an object capable of returning its members one at a time (for example: lists, tuples, dictionaries, and strings). They can be used in for loops. The  map()  function takes two parameters (in this order): The function that we want to apply to each item of the iterable. The iterable. 🔸 Example If we have this line of code: map(f, [1, 2, 3, 4, 5]) Where  f  is a function that is already defined in the program, this is what happens behind the scenes: The function  f  is called with the first element of the iterable as the argument (in this case, 1). That function call is completed and a value is returned (if the function returns a value). The same process is repeated with all the items of the iterable. In this ca

Intro to Python Errors and Exceptions: Behind the Scenes

Image
📌 Intro to Python Errors and Exceptions: Behind the Scenes ⚠️ Hi! Welcome to Week 4 and to this short introduction to Python errors and exceptions. This topic is essential for the process of debugging. When there are errors or bugs in a program (syntax or logical errors), you can usually detect them and correct them by reading the error message displayed. It’s like working as a detective 🔎. You need to read the error message, interpret it, and try to guess what might be causing the problem. It’s actually pretty fun if you think about it. You can fix the program by solving the “puzzle” and we usually learn very much from long debugging sessions. You need to do research, experiment, test, and fix, so they are amazing opportunities to learn. It all begins with a simple error message, and this is what we will discuss in this short introduction, a few of the different types of error messages that you can get in a Python program. Let’s begin! Vocabulary Exception : an excepti

Try-Except-Else-Finally: Behind the Scenes

Image
📌 Try-Except-Else-Finally: Behind the Scenes Hi! Welcome to this short tutorial where you will learn how  exception handling  works behind the scenes when you use  try-except-else-finally  blocks. Let’s begin! 👍 This is the basic structure used to handle exceptions in Python (diagram below). We have four blocks: try:  this is the code that you will try to run. What happens after this depends on whether an exception was thrown or not. except:  this block handles the exception if it occurs when the try block is executed. else:  this code block runs only if no exceptions were thrown in the try block. finally:  this block always runs, even if there were exceptions in the try block. As noted in the lecture, this block if very helpful for “clean up code” such as closing files. 💡 Note:  the else and finally blocks are optional. If there is a finally block, else must be included before the finally block. 🚩 Exception Thrown in the Try Block Let’s see what ha

Python Numeral Systems (Decimal, Binary, Octal, Hexadecimal): Behind the Scenes

Image
📌  Welcome to… Python Numeral Systems! 👋 Welcome to this new tutorial. This time, you will learn about a very interesting aspect of Python, how you can work with numbers in different numeral systems (decimal, binary, octal, and hexadecimal). Let’s begin!  😀 ✨ Intro to Numeral Systems Typically, when you work with numbers in Python, you use the  decimal number system . For example, when you enter the number 1101 in the interactive shell, you see this: >>> 1101 1101 The same number is returned because the “default” numeral system in Python is the decimal numeral system (base 10). Note:  the  base  of a numeral system is a key concept. The decimal numeral system has base 10 because it represents numbers using 10 digits (0-9) The resulting number is obtained by multiplying the digit by 10 raised to its corresponding power, moving from 0 for the rightmost element and increasing by one as we move to the left, as you can see in the following diagram: That