Search This Blog

Sunday, May 24, 2020

Tokens and Data type in Python Programming

Mr. abhijeet dwivedi

Python Programming:

In this tutorial, you will learn:-

      Token:

 


 

 

The smallest individual unit in a program is known as token in python.

There are 5 types of token available in python programming:-

1. Identifiers:-

An identifier is a name used to identify a variable, function, modules, or another object, etc.

Rules:-

* Identifiers can be a combination of letters  in lowercase(a to z) and uppercase(A to Z) or digit(0  to 9) or an underscore(_)
* Identifiers can't be stored with digit.
* Keywords can't be used as an identifier.
* Special symbol like : !, @, #, $, %,etc are use as identifiers.
* Identifier can be of any length.

2. Keyword:-

Keyword is a reserved words that have a special meaning in python programming
 * Keywords can't be used as identifiers.
* Python 3.7 has 33 keywords.
* All keywords except true, false, & name are the lower case and they must be written at it is.3.

 3. Operator:-

Operator are sign which is used to generate an expression or to perform any calculation. Python uses a nonalphanumeric character and character combination as an operator.
please visit our operator post to get more information, python operator.
For example:-   x+y=c;    ----- Airthmatic operator.

4. Delimiters:

Delimiters are the symbols and symbols combinations used in expression like list, dictionaries, string, etc.
For Example:-  {, }, [, ], :, =, +=,>>,etc

5. literals:-

A literals is a numbers or string that appears in a programming.
For example:-   
42  ---  Integer type   (literals)
29.8 ---- float 
"codeswithabhi"  -----string
12+i     --- complex

 Data type:-

  

1. None:

In this data type not any value stored means null value carries none data type.

2. Numeric:

* Integer:

In integer we have to take all values in integer data type.
For e.g:  >> abhi=10   ---int value
if we wanna confirm our data type so, you can use this function to check to check type of data type:
>> type(a)
<class'int'>

* Float:-

In this type of data type, we have to take all values in floating values (Decimal values).
For eample:      >>c=10.34  ---- Float value
If we wnna check type of data type that we takes type function :
>>Type(c)
<class'float'>

* Complex:

The complex data type holds the comples data type.
For exmple:   a=100+3k
print("type of data type",a  type(a))
<class'comple'>

* Boolean:

The boolen check the condition of two variables and also comparing two values.
For example:
>>a=10
>>b=100
>>a>b
>> False

3.  List :

In python we can create and also store data, and this data may be in integer, flaot, string, also combination of all 3 types of data type:
For Example:  >>abc[1,2,3]
        type (abc)
   <class'list'>
We discuss list in brief in our next post..

4. Tuple :

It is colllection of objects enclosed within ( ).
For example: >> a= (9,1,2)
          >>type(a)
      >> <class'tuple'>

There are some charactrstics of tuple:

* Hetrogeneous :
* Immutable :
 * Duplicate
We will discuss more in detail in our next upcomming post...

5. Set :

A set is an un oredered collection of items, Every set element is unique (no duplicates)p and cannot be changed.
For example:    >> A=(1,2,4,1,7,2)
>>print(A)
>>1,2,4,7    ----- here repeating number is avoid by set
And if we wanna check type of set:
>>Type(A)
>> <class'set'>
We discuss this topic in detail in our next upcomming post.

6. String :

The group of character is know as string. In pytho we can eaisly access string rather than another various programming language.
For example:
>> S="codeswithabhi"
Print(S)
codeswithabhi
And we can also check it by using type function
>>type(S)
<class' string'>

Learn complete Complete course





7. Range:

In other programming language we use loops and give condition to access a particular condition which is given by programmer, similary range gives a also a path, condition, and printing range.
For example:
>>Range(1,10) 
 So, in this condition interpreter print only 1 to 9.

8. Dictionary:-

Dictinary in python is an un ordered collection of data values , used to store data values like a map, for every values assign a key.
For example: 
>>d={'abhi':'codes','hello':'abhi'}
>>d.key
>>dict.key(['abhi':'codes'])  -- so here we print key
d values 
dict.values(['hello':'abhi')    ---here we print values.


Thanks for reading....

If you any doubt related this topic please drop your question in comment box.

Saturday, May 23, 2020

Python Variables - Codes With Abhi

Mr. abhijeet dwivedi

Python Programming:-

In this tutorial, you will learn:-

Variables:-

 

  In Python, a variable is considered as a tag that is tied to some value. In other words, variables are a type of container which holds some value. A variable name can be in alphanumeric type but not start with a number. For e.g: name1=100
Python considered variables as an object


 .

Variable assignment:

In python programming language there no need to declare or defined in advance as a case of another programming language.
Let, create a variable and assign value.
>>n=100
>>print(n)
>>100
so very easy you can assign any value in a variable and print it using print() function which is already stored in python's library.

Multiple variable assignment:-

In other programming languages like c, c++,etc We need to declare and assign like this:
a=10;
b=10;
c=10;
 and then print, but in python,we can assign value in only one line like this:
>>a=b=c=10;
>>print(a)
>>print(b)
>>print(c)
>>10
>>10
>>10

 



For example, suppose we take,

>>a=10

      a ------Tag name

   10

   1002    ---------Address

>>Print(a)

10        ------- - output

type(a)   ---by type function we find the type of variable

<class' int'>    -------- type of datatype

id(a)     ---by this id function we can get the address of the value

1002     -------address

So, in python  "a" is a type of tag we can not say it variable in python it is just a tag that carries integer value.
As we know that in other programming languages a variable takes an address in memory, but in python the value takes an address.
And one more thing suppose if we take two types of the same value and try to take in a different variable like this :
>> a=10  
>> b=10
So, in this situation 10 already takes one address, and when the interpreter read b's value it cannot give another address to b's  10, it just combines both a and b into one tag which has a value 10.

Rules for variable declaration:-

1. Every variable should start with alphabet or underscore (_)
2. No space is allowed in variable declaration.
3. Except underscore (_) no other special symbol is allowed in the middle of the variable declaration
4. A variable is written with a combination of letter, number, & any special character

For example:- 

* a
* name 
* abhi12
* _city
* codewith_abhi
* Codeswithabhi
so this is some variable declarations



Python


Thanks for reading and if any doubt related to this topic ask your question below comment box.







Thursday, May 21, 2020

Introduction and History of Python in brief for beginners

Mr. abhijeet dwivedi

               Python Programming:-

In this tutorial, you will learn:-

Introduction of Python:-


Python was developed by Guido Van Rossum in year in 1991 at Stichting Mathematisch Centrum in the Netherlands as a successor of a language called ABC.
* Python is a program that combines features of C and Java.
* By the T.V show Manty python's flying circus, this programming language got the name "Python".
* Python is a powerful object-oriented programming language, comparable tp pear, Ruby, and java.

Features of Python:-

1. Easy to learn and use.
2. The programming language Python is very easy because of its easy syntax, and it is a high-level programming language that gives the user to write a code in English.
3. The python is object-oriented programming.
4. The python has a huge library, which is very helpful for the programmer in writing programs and also has many modules. 
5. Python is an interpreted language. The interpreter executes the code line by line at a time.
6. Python can run different platforms like Windows, Linux,  and Unix, etc.
7. The python is case sensitive. 

History of python and version:-

* The planning of python had started in the 1980s.
* But the real work and implementation had started in 1989.
* And finally published on 27 Feb 1991. 
* Python was developed by Guido Van Rossum in year in 1991 at Stichting Mathematisch Centrum in the Netherlands as a successor of a language called ABC.
* ABC language and modula-3  had a major influence on the python programming language.
* In 1994, The python released their Python 1.0 with some features like map, filter, etc.
* In 2002, The python released their Python 2.0 with features like garbage collection system.
* In December 2008, Python 3.0 had released (also called "Py3K").

Python Versions List:-

Python version
 Released Date
Python  0.9.0
 February 1991
Python  1.0
 January 1994
Python  2.0
 October 2000
Python  3.0
 December 2008
Python  3.1
 June 2009
Python  3.2
 February 2011
Python  3.3
 September 2012
Python  3.4
 March 2014
Python  3.5
 September 2015
Python  3.6
 December 2016
Python  3.7
 June 2018
Python  3.8

 Python application:-

 Generally, the python is mainly developed for developing software, web application, desktop application, and games, etc.

1. Web application:-

Python is used for developing web applications. Python has a huge library so, when we develop any web application through python its looks and their features are so good.  Some important developments are PythonWikiEngines, etc.

2. Desktop GUI application:-

The Tkinter is a very popular platform where we develop various types of GUI desktop applications.

3. Console based application:-

We can develop console based application easily by python.

4. Games and 3D application:-

The python is also very popular for games and 3D games.

5. Mobile app:-

We can use python for development of mobile application. like social media apps , many more. 

6. Scientific and numeric:-

Pyhton is widely use in scientific and numeric. Some useful library and package are SciPy, Pandas, etc.

7. Data science:-

Python is also used in Data science.

8. Machine learning:-

Python is also use for machine learning, their are some popular platform like Scikit learn & Tensor flow.

9. Data analysis:-

Python is also widely used in data analysis, and their are some platforms are Matplotlib, Seaborn, etc.

10. Business application:- 

Tryton is high level platform, where we design  some appliction related to our business.

What is byte code in Python:-

Byte code - Byte code represent the set of intstruction created  by python developers representing all type of operation like arithmatic operations, memory related operation, etc.
Size of one byte code is 8 bits.
The location of byte code in the .pyc file.

Python compiler:-

A python compiler converts the program source code into byte code.

Types of compiler in pythons:

* CPython
* JPython/ Jython
* PyPy
* RubyPython
* IronPython
* StacklessPython
* Pythonxy
* AnacondaPython

If you complete this so, now I recommended to learn python variable 

 Thanks for reading.....

if anyone have any doubt related to this topic drop your question in comment section.

Tuesday, May 19, 2020

Operators full explaination in C Programming.

Mr. abhijeet dwivedi

                          C-Programming

In this tutorial, you will learn:

Operators:-  

 


Operator are sign which is used to generate an expression or to perform any calculation.
For example:-    x=y+z;

Types of operator on the basis of expression performance:-

1. Uninary operator:-

When a single variable or operands use and operator is known as Uninary operator
For example:-       {x++  or  ++x}
                                {x--  or  --x}

2. Binary operator:-

When more than one or two variable or operands uses any opeartors to generate an expression known as Binary operator.
For example:     x=x+1;
                            x=a+b;

There are some types operator available in C.

* Airthmatic operator  (+, -, /, *)


For example:-
int x=1, y=1, s;
 s=x+y;  ------------(here we use additional operator).

* Relational operator  (>, <, <=, >=)

Relational operator are used for comparison of two values to understand the type of relationship.
A simple defintion is here we are omparing two value and two operand and in last we get result which one is greater, smaller, etc.
For example:-
int x=1, y=3;
if(x>y)
{
printf("x is greater");
}
else
{
printf("y  is greater");
}

OUTPUT:-

Y is greater.

* Logical operator   {AND(&&), OR(||), NOT(!)}


For example:
int x=10, y=100;
if(x=10 && y>x)
{
printf("code with abhi")
 }
else
{
printf("wrong choice");
}

OUTPUT:

Code with abhi

* Increment / Decrement  (--, ++)

The increment operator add +1 to it's operands whereas, The decrement operator subtract -1 to it's operator.
For example:
int x=1;
for(x=1;x<5;x++)  ------here we use increment operator.
{
printf("%d",x);
}
OUTPUT:
1
2
3
4

* Assignment operator (=)
An Assignment operator is used to assign value to a variable.
For example:
int x=1;     ------- assignment operator
printf("%d",x);
}

OUTPUT:

1

* Equality operator  (==)

The equality perator is used to compare two values or expression.
For example:
Int x=10, y=100;
if(x==y);
{
printf("10");
}
else
{
printf("0");

}

OUTPUT:

 0

* Short hand operator

The shorthand operator is used to express anything in shorter way.
For example:
int x=10;
x=+1;
printf("%d",x);

OUTPUT:

11

* Conditional / Ternary operator

The conditional operator is used for check  whthere condition is triue or false. Ternary operator is used to test a condition either condtion will be true or false. In ternary operator they have to use (? , :) sign for execute the true or false condition by using the following syntax.
(Ternary operator is subsitiute of if else)
Syntax:-
(Condition test) ? (statement 1) : (statement 2) ;
For example:-
#include<stdio.h>
#include<conio.h>
void main()
{
int l, x=50 ; y=20;
l=(x>y) ? x : y ;
printf('largest no  is = %d",l);
getch();
}

OUTPUT

Largest no is = x

Saturday, May 2, 2020

Program which are frequently asked in interviews [C-Programming]

Mr. abhijeet dwivedi

          C-Programming:- 

In this tutorial you will learn:- 

 Program which are frequently asked in interviews


1. Fibonacci series:

#include<stdio.h>
int main ()
{
int n1=0, n2=1, n3,number;
int= i;
printf("enter the number of element");
scanf('%d%d",&number);
 printf("\n%d%d",n1,n2);  //printing 0 and 1
for(i=2 ; i<number ; ++i) // loop starts from 2 bacause 0 and 1 is already printed
{
 n3=n1 + n2 ;
printf("%d"n3);
n1=n2;
n2=n3;
}
return 0 ;
}

OUTPUT:

enter the number of element :7
0 1 1 2 3 5 8

3. Prime number:-

#include<stdio.h>
int main ()
{
int n, i,  m=0, flag=0 ;
printf("Enter the number to check prime :");
scanf("%d",&n);
m=n/2 ;
for(i=2 ; i<=m ; i++)
{
if(n%i==0)
{
printf("number is not prime");
}
flag=0 ;
break;
}
}
if(flag==0)
{
printf("number is prime");
return 0 ;
}

OUTPUT:

Enter the number to check prime: 11
number is prime
3.

 4. Palindrome number:

#include<stdio.h>
int main()
{
int n sum=0, rev temp;
printf("enter number to check palindrome number");
scanf("%d",&n);
temp=n;
while(n>0) 
{
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(temp=sum)
{
printf("number is palindrome");
}
else
{
printf("number is not palindrome");
}
return 0 ;
}

OUTPUT:

enter a number to check palindrome number:  121
number is palindrome

5. Factorial number:-

#includestdio.h>
int main()
{
int n, f=1, i;
printf("enter any number");
scanf("%d"&n);
for(i=1 ; i<n ; i++)
{
f=f*i;
}
printf("fact is: %d",f);
return 0 ;
}

OUTPUT:

enter any number: 3
fact is 6

 6.Amstrong number:

#include<stdio.h>
int mian()
{
int n, r, c, temp, sum=0;
printf("enter any number to check amstrong number");
scanf("%d",n);
temp=n;
while(n>0)
{
r=n%10;
c=r*r*r;
sum=sum+c ;
n=n/10;
}
if(temp=sum)
{
printf("nummber is amstrong");
}
else
{
printf("number is not amstrong");
}
return 0;
}

OUTPUT:

enter any number to check Armstrong number: 153
number is amstrong number


7. Swap number using without using third variable:-

#include<stdio.h>
int main ()
{
int n, a=10 , b=20;
printf("before swapping: a=10 ,  b =20);
a=a+b;  //a=30(10+20)
b=a-b; //b=10(30-20)
a=a-b; //a=20(30-10)
printf("after swapping :\n a= %d  b= %d",a,b);
return 0;
}

OUTPUT:

before swapping  a=10 , b=20
after swapping
a=20  b=10

8. Swap number using third variable:

#include<stdio.h>

int main ()

{

int a=10, b=20 , c;

printf("before swap a=10 , b =20");

c=a;

a=b;

b=c;

 printf("after swapping: a=%d , b=%d", a ,b);

return0;

}

OUTPUT:

before swapping: a=10 , b=20
after swapping: a=20 , b=10

9. Matrix multiplication:

In this program, we multply two matrices of any order but the order of row and column must be  same other wise the compiler ma confuse and show some errors in your program.
Include<stdio.h>
int mian()
{
clrscr();
int a[3][3] , b[3][3] , c[3][3];
int i, j, k;
printf("enter the elements of matrix a\n ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",a[i][j]);
}
}
printf("enter the element of matrix b\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",b[i][j]);
}
}
 printf("multiply of matrix a and b is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++) 
{
c[i][j=0;
for(k=0;k<3;k++)
{
c[i][j]=a[i][j] * b[i][j] ;
}
}
}
printf("result is = \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf('%d",c[i][j]);
}
printf("\n");
}
return0;
}

OUTPUT:-


enter the first matrix element=
1 1 1
2 2 2
3 3 3
enter the second matrix element=
1 1 1
2 2 2
3 3 3
multiply of the matrix=
6 6 6
12 12 12
18 18 18

10. Convert Decimal to Binary:-

Decimal Number

A decimal number is a base 10 number because it ranges from 0 to 9, there are total 10 digits between 0 to 9. Any combination of digits is a decimal number such as 23, 445, 132, 0, 2, etc.

Binary Number

The binary number is a base 2 number because it is either 0 or 1. Any combination of 0 and 1 is a binary number such as 1001, 101, 11111, 101010 etc
 #include<stdio.h>
int main()
{
int a[10] i, n;
printf("enter a number to convert");
scanf("%d"&n);
for(i=0;n>0;i++)
{
a[i]=n%2;
n=n/2;
}
printf("binary is :\n");
for(i=i;i>=0;i--)
{
  printf("%d",a[i]);
}
return 0 ;
}

OUTPUT:-

Enter the number to convert: 5 
Binary of Given Number is=101 

Thanks for reading.........