2.1 Python basics
Tags: python, beginners, webdev
Published: 2019-11-02 08:50:14

Hello guys,
    From this post i am going to start Section-2 (Python basics). If you did'nt
 read the previous post regarding the installisation of python then i suggest first go through this provided link  https://dev.to/mohit355/download-and-install-python-3-x-1boo

Now,let's start,
#Print() function
  =>> This function is used to print something on the screen.  One example shown in the previous post.
  =>> Syntax :   print("  ")   or print('  ')
  =>> you can use both single quotes or double quotes but one at a time.       
  =>> Inside the double quotes you can write any thing can be printed on the console screen (if you are using any IDE)
if you are using the Python IDLE then it will be printed on the same screen.

  Let's take an example to explain what print function does. I want to print HELLO WORLD on the screen.
  so i write print("HELLO WORLD")  or print('HELLO WORLD') and it will print it on the screen .
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4oo3lfbrd3vgf5ovob3r.png)

String : Collection of characters inside "Double quotes" or 'Single quotes' 

=>> Since we print HELLO WORLD, actually it is a string and that's why we write it in a single or double quotes.

Some Point to Know -
  1. If you are using double quotes then inside the double quotes you can use single quotes and vice versa
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/g9oco922qrdf5jnasy4b.png)

  3. double quotes or single quotes are not used inside double quotes or single quotes respectively
 otherwise it will show you an error (Syntax error)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/lmqnlqc5xxvg6i9eoclp.png)

#Comment in Python
  1. Comment is for the user who is going to read the written code, comments make easy for the reader to understand the code
  2. comment is ignored by the Python interpreter means when you run your program comment line cannot be treated as line of code
it just ignored (that's why this is only for the user)
  3. Comments in Python start with the hash character (#) , by using hash we can comment a single line
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/njv2098hexmmqf6dlby9.png)

  4. if you want to comment  multiple line then use triple quotes (''') at the beginning of the comment and at the end of the comment
  5. A comment may appear at the start of a line or following whitespace or code, but not within a string literal.
 A hash character within a string literal is just a hash character.

#Escape sequence in Python
  1. Escape characters are characters that are generally used to perform certain tasks and their usage in code directs the compiler to take a suitable action mapped to that character.

  2.In Python strings, the backslash "\" is a special character, also called the "escape" character. 
  It is used in representing certain whitespace characters
 Example of Escape characters :-
  a)  \ newline   ( Backslash and newline ignored)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/n8k75mahzz9x0l3241c9.png)

  b)  \\           ( Backslash (\) )
  c) \'            ( Single quote (') 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/cf2yogtbf39r79tvaqa2.png)

  d) \"          ( Double quote (") )
  e) \b          ( ASCII Backspace (BS) )
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/mwkhezqkm2f26vp836eu.png)

  f) \n           ( ASCII Linefeed /Break the line(LF) )
  g) \t           ( ASCII Horizontal Tab (TAB) )
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/zlpsnzo9xsif3dhki2b7.png)

  h) \000          ( Character with octal value 000 )
	      (000 may be any integer value according to octal value )

Suppose we want to print Hello using octal value of H-110,e-145,l-154,157 
so we can write print("\110\145\154\154\157") to print Hello on the screen
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/gur8dlogaj1ufklze2lc.png)

#r(raw string)
	   used to print every thing inside the quotes means is there is any escape character inside then r (raw string) make it netural and 
behaves as a simple character
Example: print(r"hello \nworld)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/xrpqsh1tbdxibl0lekra.png)it will print as it is

That's all for this. if you have any problem regarding escape character or any thing please let me know in comment box