Wednesday, September 18, 2019

type keyword in python

  Python have a built-in method called as a type. If  a single argument (object)  is passed to type() built-in , it returns the type of object.

Syntax:
          type(object)

Example:
>>> x=5
>>> s="codingpartnerr"
>>> y=[1,2,3]
>>> print(type(x))
<class 'int'>
>>> print(type(s))
<class 'str'>
>>> print(type(y))
<class 'list'>
>>> 

Tuesday, September 17, 2019

Variables in Python

            Python is a complete object oriented. every variable in python is a an object. A variable is the name used to access a value. A variable is named location which is used to store data in the memory which can be replaceable.
           Every variable have a unique name called identifier. identifier helps to variables as container to hold data which can be changed later at any time of the programming.
Ex.
>>> python=45
>>> print(python)
45
>>> 
This code creates a variable called python, and assigns to it, integer number as 45. when we ask python to tell us what is stored in the variable python, it returns that number again.

Declaring Variables in python:
   Variables in python do not need any declaration to reserve memory space. The variable declaration happens automatically when we assign a value to a variable.

There are some rules with variable name in python:
=>  it can only be an only word.
=>  it can only use letters, numbers and underscores(_).
=>  Hyphens are not allowed (-).
=>  Spaces are not allowed.
=>  it cant't begin with a number.
=>  Special characters are not allowed such as $ or '.

points to remember:
 =>  variable names are case sensitive, NAME and name are different variables.
=>  it is convention in python to use all lower case letters for variable name, using underscore(_)             separators.
=>  a good variable name describes the data it contains.

declaring and assigning a value to a variable:
Syntax:
           VariableName= "Assigning Value"
Example:
>>> blog="blogger.com"
>>> print(blog)
blogger.com
>>> 

changing value of a variable:
Syntax:
           VariableName= "new assigning value"
Example:
>>> blog="codingpartnerr"
>>> print(blog)
codingpartnerr
>>> 

Assigning multiple value to a multiple variables:
Syntax:
            Variable1, Variable2, Variable3=  "Value1","Value2","Value3"
Example:
>>> a,b,c= 45,18, 'hello'
>>> print(a)
45
>>> print(b)
18
>>> print(c)
hello
>>> 


If You like this content, so please go for a comment and give your feedback.


INSTAGRAM

Monday, September 16, 2019

Python Keywords

=>  keywords is nothing but reserved words.
=>  we can not use a keyword as a variable name, function name or any other identifier.
=>  in python keywords are case sensitive.
=>  there are 35 keywords in python.

   following is the example of print keywords in python.

Example:
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

Sunday, September 15, 2019

Comments in python.

      comments are non executable statements or ignore statements. using this comments we can declare user defined or customized statements in the source code.
     python supports two types of comments,
     1) Single line comment.
     2) Multiple line comment.

1) Single line comment :
      in python we use the pound(#) symbol to start writing a comment. if we want to only specify one line comment then we can use single line comment.
Example:
>>> #this is single line comment


2) Multiple line comment :
      if we have comment that extend multiple lines, one way of doing it is to use pound(#) in the beginning of each line.
Example:
>>> #print("welcome to python")
>>> #multiple line comment

Tuesday, September 3, 2019

Reading data in python.

    Python provides 2 built in functions to read a line of text from standard input
1] raw_input()
2] input()

1] raw_input() :
                        it is used to read data from the user or from the keyboard.
      it is only supports to the python 2.x versions.
    syntax:
                raw_input("message")
    example:
               we are executing this statement in latest version of python.
    >>> x=raw_input("enter a number")
            Traceback (most recent call last):
            File "<pyshell#0>", line 1, in <module>
            x=raw_input("enter a number")
           NameError: name 'raw_input' is not defined
    >>> 
             raw_input() function is deleted from latest versions of python.

2] input() :
                it is used to read data from the user or from the keyboard.
      it is supported to the python 3.x versions onwards.
   syntax:
               input("message")
   example:
       >>> x=input("enter a number:")
      enter a number:45
       >>> x
        '45'
       >>> 
              

Monday, September 2, 2019

printing function in python.

1) print : 
       print is a statement in python, it supports in the 2.x version of python.
       syntax:
                   print message
     example:
                    we are executing this statement in latest version of python.
       >>> print 'hello python'
              SyntaxError: Missing parentheses in call to 'print'. Did you mean print('hello python')?
       >>> 
                so this statement is only execute in 2.x python versions.

2) print() :
         print the given object to the standard output device. it supports in python 3.x version onwards.
    syntax:
              print("message")
   example:
               >>> print("message")
              message
               >>> 


Saturday, June 8, 2019

Python IDLE Installation process.



1. Go To http://www.python.org/download/
2. Download the latest version for windows.
3. Double click on that .exe file.
4. select install for all users, click on next button.
5. select customize python, click on next button.
6. finally click on finish button.

screenshots=>



type keyword in python

  Python have a built-in method called as a type. If  a single argument (object)  is passed to type() built-in , it returns the type of obj...