Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 1.02 KB

Python-Syntax.md

File metadata and controls

29 lines (23 loc) · 1.02 KB

Basic Python Syntax

Python 2

  1. Printing output in python 2 :- print "argument that you want to print"

  2. mathematical operators :- x = 8 y = 4 print x+y # it wil give outout of sum of x and y print x-y # it will give difference of x and y print x/y # it will give quotient when x is divided by y print x%y # it is modulo function and gives remainder when x is divied by y print x ** y # it means x^y. it is way to represnt power operator

  3. single line comments can be given by putting # before a line

  4. multi line comments can be given by putting 3 double quotes befire and after the lines.

example of putting multiline comments is : """ hello how are you """

  1. To validate a variable to be an integer or a string, use 'isinstance(, )' it accepts two parameter
  2. variable name
  3. Type to be validated example: isinstance(a, dict) , isinstance(num, integer) It return True if true else false.