Posts

Showing posts from 2017

Python 3 Tuples

The tuple data type is almost identical to the list data type, except in two ways. 1) Tuples are typed with parenthesis ( and ) instead of square brackets [ and ] 2) Tuples are immutable, whereas lists are mutable. Benefit of using tuples: You can use tuples to convey to anyone reading your code that you don't intend for that sequence of values to change. If you need an ordered sequence of values that never changes, use a tuple. A second benefit of using tuples instead of lists is that , because they are immutable and their contents don't change. Python can implement some optimizations that make code using tuples slightly faster than code using lists. E.g. fruits = ('Banana', 'Apple', 'Carrot', 'Strawberry') If you have only one value in your tuple, you can indicate this by placing a trailing comma after the value inside the parenthesis. Otherwise, Python will think you've just typed a value inside regular parenthesis. E.g. f

Python 3 Lists

A list is a value that contains multiple values in an ordered sequence. Example of list : fruits = ['Banana', 'Apple', 'Carrot', 'Strawberry'] A list begins with an opening bracket and ends with a closing bracket. Values inside the list are called items, and they are separated by commas. Getting Individual Values in a List with Indexes: Consider the above list for example, the python code fruits[0] would evaluate to 'Banana' and fruits[1] would evaluate to 'Apple' and so on. The integer inside the square bracket that follows the list is called an index. The first value in the list is at index 0, the second value is at index 1, the third value is at index 2 and so on. Indexes can only be integer values not floats. For example, fruits[1.0] will give error. Lists can also contain other list values. The values in these lists of lists can be accessed using multiple indexes, for example: fruits = [['Banana', 'App

Python 3 Variables

Variables are nothing but reserved memory locations to store value. This means when you create a variable you reserve some space in memory. Python is completely object oriented and not "statically typed". You no need to declare variables before using them, or declare their type. Every variable in python is an object. Every value in python has data type. Different data types in python are: Numbers String List Tuple Dictionary Python Numbers: Number data types store numeric values. Number objects are created when you assign a value to them. For example: var1 = 32 var2 = 42 Python supports two types of numbers: Float Integers To define a floating point number, you may use the following: pi = 3.14 print(pi) You can redeclare variable even after you have declared once: f = 0 print(f) f = "cat" print(f) Concatenate Variables: You can concatenate variables of same type. f = "dog" + "cat" print(f) For

In System Programming Vs In Application Programming

Flashing new firmware in the microcontroller can be done in two ways: 1. In System Programming:  The process in which a device can be flashed without removing the chip from the board.. E.g. Flashing the PIC Microcontroller using PICKit In order to perform ISP operation, the microcontroller is powered up in a special mode: "ISP Mode". ISP mode allows the microcontroller to communicate with an external host device through the serial port such as PC or terminal. Microcontroller receives commands, data over the serial from host, erases and reprograms the code memory.. Once ISP operations has been completed, the device is reconfigured so that it will operate normally the next time it is reset or power removed and reapplied. Microcontroller by default gets factory shipped by a bootloader. This bootloader will check the state of the pin on boot, and depending on it will either start the user program or will wait for downloading firmware over UART. 2. In Application Progra