Skip to main content

Posts

Showing posts from September, 2020

Indentations in Python

  INDENTATION : Indentation is nothing but giving proper spaces they are like {} braces don’t need to mention any {} braces to indicate a set of code or code so our compiler or interpreter need to understand from where to stop and where to continue again .our compilers or interpreters don’t know the order in which the statements of the code should be executed so we use indentations to specify compilers to execute them in order ** we all know that python is very easy and a simple language which means we don’t need to mention datatypes and syntaxes also will be very easy to understand when   compared to other languages but if you don’t give proper indentation   then it shows us hell, so we need to use proper indentation or else you will be ending up seeing that that “INDENTATION ERROR”   message . Ø   Actually, indentation is nothing but giving spaces before the statements Ø   Actually, we use tab or space for indentation in python, by default python uses 4 spaces which means a tab

BIT-WISE OPERATORS

  Bitwise operators BITWISE OPERATOR:   BITWISE Operator in python are used to perform bitwise calculations on numbers (integers) Ø   The name itself suggests that something to do with binary format like bits. Ø   We cannot directly perform operations on integers so we need to convert them into binary format and then we need to do. Ø   Result will be in decimal format. Types of bitwise operators: Ø   Bitwise And - & Ø   Bitwise OR - | Ø   Bitwise NOT - ~ Ø   Bitwise xOR - ^ Ø   Bitwise right shift - >> Ø   Bitwise left shift - << 1.   Bitwise AND (&):   this operator returns 1 if both the values are 1 or else it returns 0           x        y       x&y    1       1         1    1       0         0   0       1         0     0       0         0     Example:   a=15 -    1111                       B=6 -     0110                                                     a & B = 0110                                 = 6 (DECIMAL)       2

Number System in Python

  Python generally supports integers, fractional values and complex numbers and we have data types for them like int for integers, float for fractional values, and complex for complex numbers, we can understand that but if our computer wants to perform certain operations on bits or some other operations then we need to convert them into some number systems like binary, octal, hexadecimal. These are the three different number systems. Number conversions are used in programming languages because we cannot directly use some operators like bit-wise operators, we need to convert decimals into binary and sometimes we need to convert binary format of a number to decimal, so we use number conversions there Actually, number conversions are done on 4 types 1.       Decimal 2.       Binary 3.       Octal 4.       Hexadecimal 1. Decimal to binary:                               Binary – which means 2, we can only use 2 digits 0 and 1 so we call them as binary digits nothing but bits.

Index in Python

  Generally, we add elements in lists, tuples and we delete items, insert elements etc but how can we do that, how can we access a particular element, this is done by using index number. PDF FOR  INDEX IN PYTHON   Ø   Index numbers are nothing but numbers which are given to elements in a list or tuple or array etc to access them. Ø   Index number starts with zero and ends with one less than the given number but For example  List = [1,5,8,13,24,31] 0  1  2  3   4   5 Ø   Each index refers to one element, as we know here the elements in the list are 6 but the maximum index will be 5 this is because index starts with zero so maximum index will always be one less than the length of list or tuple or array etc. ADVANTAGES in Python: Ø   It makes our work easier like we can easily delete the element we want to delete by just using its index number. Ø   There are lot of ways to print elements using index values. Ø   By directly using that element in square brackets For exampl

Contact form

Name

Email *

Message *