• Microcontroller v.s. Microcomputer

    Microcontroller (MC, UC, μC, or MCU) A microcontroller is a compact, integrated computing device designed to perform specific, dedicated tasks rather than general-purpose computing. Unlike a typical computer, a microcontroller does not run a full operating system. Instead, it executes a single program or set of instructions stored in its memory to control or interact…

  • Python Reading and Writing Files

    Read From File To read from the file, you can use the open function to open the file. It opens it and returns a file object that users can use to read or modify the content of that file. The syntax is open(file_name, mode), the file_name is the name of the file you want to…

  • Python Input

    Input The input function is used to get input from the user in string data type (If the user enters [1,2,3], it will be “[1,2,3]” – it becomes a string, not a list) Example age = input(“Enter your age: “) # Prompt the user to enter their age; the input is returned as a stringprint(“Your…

  • Python Pattern Matching With Regular Expressions

    Search for a value Some variable data type such as string, list, set and tuple allow you to search them by using the in keyword Example temp_list = [1, 2, 3] # Create a list with elements 1, 2, 3temp_string = “Hello World!” # Create a string variable with value “Hello World!”if 1 in temp_list:…

  • Python Strings

    Indexing You can slice a string using smart indexing [] and : or :: Example temp_string = “abcdefghijk” # Create a string variable with value “abcdefghijk”print(temp_string[1:]) # Slice from index 1 to the end and print thatprint(temp_string[2:6]) # Slice from index 2 up to (but not including) index 6 and print thatprint(temp_string[::-1]) # Reverse the…

  • Python Dictionaries

    Dictionary A dict is a data type that stores a sequence of key:value pairs (a key is associated with a value). Keys have to be immutable and cannot be duplicated. Notice that dict and set use the same syntax {} . A dict will have key:value pairs, whereas a set, will only have values. Dictionaries…

  • Python Lists

    List A list is a data type that stores multiple\any data types in an ordered sequence. It is mutable and one of the most used data types in Python. You can store integers, floats, strings, and so on. Example temp_list = [1, 2, 3, 4, 5] # Create a list named temp_list containing the numbers…

  • Python Functions

    Function Structure Function is a reusable block of code that has 2 parts: The following snippet will declare a function, but it won’t execute it: Example def example_1(): # Define a function named example_1    temp_val = 10 # Create a local variable temp_val and assign it the value 10    print(temp_val) # Print the…

  • Python Decision Making and Loops

    Control Flow Control Flow in Python refers to the order in which the statements and instructions in a Python program are executed. By default, Python executes code sequentially from top to bottom, but control flow structures allow you to make decisions, repeat actions, or change the execution path based on conditions. The main control flow…

  • Python Basics

    Expression A combination of values (E.g. 5) and operators (E.g. +), which will be evaluated to a value Example 9 * 98 # multiplies the numbers (result = 882)/ 1 # divides by 1 (so the value stays 882)print() # displays the result in the console Result Operators Precedence Is the order of operations (PEMDAS)…