Problem-Solving-with-Python

A course for basics of Python during post graduation (first sem.)

View on GitHub

The Beginning

Remember!

  1. Can follow any book that covers syllabus
  2. Don’t follow websites until they ain’t trusted

Table of Content

1. Topics:

  • Information & Data
  • Analog & Digital System
  • Bits, Bytes & Bit Patterns
  • Numeral Systems
  • Data Encoding

2. Prerequisites:

  • Basic Maths

Information & Data

Information: A fact/piece of knowledge about real world
Data: Representation of Information in a format that can be stored, processed by the computers

The data hava no meaning on its own, alone!

eg.:

  1. A credit card number or someone’s name is a piece of an information
  2. When Credit Card no. or name is used for some specific purpose, it becomes data (as here the data element are stored on the Credit Card using magnetically charged particles)

Information can be:

  1. Encoded
  2. Quantified

Encoding

Converting information into Data

Quantifiable Info:

  1. Continuous:
    • Can go infinite
    • Can be fractional, too
    • Associates with Physical Measurement
    • eg.: height, weight
  2. Discrete:
    • These are finite, i.e. countable
    • Non-Fractional (integers only)
    • Associates with Physical Measurement
    • eg.: number of days in a month

Analog & Digital System

1. Analog

- Encodes real world info as continuous

- Operates on Continuous data

2. Digital

Bits, Bytes & Bit-Patterns

Bits:

The term Bit comes from Binary Digit.
As it’s understood that a binary itself deals with two. Hence, there is only the scope of either of the 2 values, i.e. zero (0) & one (1).

Hence formally, a 0 or 1 is considered as a bit in the binary number system. Usually we represent a the term bit by a lower case ‘b’ (b).
Sometimes these values also represent ‘True & False’, or ‘On & Off’!

A group of 4 such bits is termed as a Nibble.

Byte:

A group of 2-nibbles or 8-bits is called a Byte. It is represented by an upper case ‘b’ (B).

Bit-Strings or Bit-Patterns:

A sequence of bits can be used to represent different numbers or data. To do so, we often group the different number of the bits.
Here a few terms in the the set of bits of different length:

210 = 1,024

Data Measurement Size
1 Bit Single Binary Digit (1 or 0)
1 Byte 8 bits
1 Kilobyte (KB) 1,024 Bytes
1 Megabyte (MB) 1,024 Kilobytes
1 Gigabyte (GB) 1,024 Megabytes
1 Terabyte (TB) 1,024 Gigabytes
1 Petabyte (PB) 1,024 Terabytes
1 Exabyte (EB) 1,024 Petabytes

Numeral Systems

There are so many ways to represent the data numerically that are known as Numaral Systems. For eg.: Decimal, Binary, Roman etc…
Roman: I, II, III, IV ….
Decimal: {0,1,2,3,4,5,6,7,8,9}
Binary: {0,1}
Octal: {0,1,2,3,4,5,6,7}
Hexadecimal: {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} …

ASCII

We use different sets of collection of bits to represent it as a different number system eg.:

  • the binary number system can only accommodate 21 = 2 unique values i.e. zero (0) & one (1).
  • the octal number system can accommodate 23 = 8 unique values, i.e. ranging between 0-7 i.e. {000, 111}.
  • the hexadecimal number system can accommodate 24 = 16 unique values, i.e. ranging between 0-F i.e. {0000, 1111}.

Positional Numeral System

A positional (numeral) system is a system for representation of numbers by an ordered set of numeral symbols (called digits) in which the value of a numeral symbol depends on its position. For each position a unique symbol or a limited set of symbols is used.

pos.num. sys.

Conversion

We are often interested to convert the values from one to another number system. The above mentioned formula can be used to convert the them. These conversions can be for the following types:

  1. Binary to Decimal
  2. Binary to Octal
  3. Binary to Hex
  4. Decimal to Binary
  5. Hex to Binary etc..

Covnersion of Real Number

Example of bin to dec REAL number conversion
eg.: 42.31 = 2x100 + 4x101 + 3x10-1 + 1x10-2

Data Encoding

The different formant of data is needed to be encoded ultimately in either of the 0 & 1. The data can be of various types as well. So, mostly we have to deal with following encodings:

Character Encoding

Char

Color Encoding

There are basically 4 main colours whose intensity can lead to all the different shades. Char

Image Encoding

Generally the images are classified into 4 types based on their shades. Main three are given below:
a) Black and White (#00 or #ff)
b) Gray Scale (#00 to #ff)
c) Coloured (#000000 or #ffffff)
Char

Sound Encoding

Char


Some Other Common Issues

We deal with some other issues too, while converting the data from one form to another. As -

Approximation & Precision

Errors


Back to home