PYTHON

 PYTHON BASICS
















It is used for:
web development (server-side),
software development,
mathematics,
system scripting.

What can Python do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready software development.

Why Python?
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-oriented way or a functional way.

------------------------------------------------------------------------------------------------------------------------
PROGRAMMING:

-  #!/bin/python -> is the mandatory first line of the python file
-  >>> represent the python shell
-  python is a indent based programming. The code blocks are seperated from the space/tab provided
-  It executes the sequence top - down.
-  Its a stop on error principle. Where there is no pre-processing. Ex: any error in line3, will not stop executing line 1,2

Basics:
- Functions are defined using the keyword def
   def function-name(arguments):
            #function body
- To call the functions, use like below block
   if __name__ == "__main__": 
            Fun_name()
-  import is the keyword used to include the header files
-  Keywords:
   - Special keywords : True, False, None (boolean representation of 1 and 0, none)
   None is not the same as 0, False, or an empty string. Its a datatype of its own (NoneType) and only         None can be None.
   If we get to the end of any function and we have not explicitly executed any return statement, 
   Python automatically returns the value None.
   - logical operators : {and, or}(Return the first True value.if not found return last), not. 
   - Controls : assert (with messages), break, continue
-  whitespace is used for the indentation of the blocks
-  the indent space should not be varied across the code

I/O Stream:
- print (var_name / string) will help to print on the console. print is a function. use , to list separated val.
    ","(comma) is the delimeter to seperate the list of values.
- input("Enter here: ") will help to accept the user input. Return type is string. However, we can type-cast it. 
-  input() and raw_input() are the 2 ways to accept the console input.
   input() doesn't evaluate. But raw_input() evaluates expression. Ex: 2+3 is assigned as str in input(). but 5 in raw_input()
   in python3, raw_input is deprecated. eval(input()) is the equivalent function for raw_input()
-  multiple inputs are possible with split and list.
   Ex: a,b = input().split(separator, maxsplit) and a,b=[int(x) for x in input().split()]
-  format helps to print the values in the specified position
-  Assignment: the multi line assignment is possible using
parentheses (), braces {}, square brackets [], semi-colon (;), continuation character slash (\)

Comment:
# is used for single line comment. For multi line comment, we can use "   "  or '  '
- declaring the multiline comment is possible with  '''  text '''   or """  text """  (3 single/double quotes)

Data Type:
- For declaring the variable, user need not know the data type. The assigned values will be type casted
- We can change the data type of the variable after it is initialized.
- can assign values for multiple variables. x, y, z = "Orange""Banana""Cherry"
- + is supported to add or concatenate the variables.
- Data types: str, int, float, complex, list, tuple, range, dict, set, frozenset, bool, bytes, bytearray, memory view.
-  type is the keyword to determine the data type of the variable
- there is a index access or the slicing option available in the string. 
     b = "Hello world" -> print(b[0]) and print(b[2:5]) is possible
- string options available.
     https://www.w3schools.com/python/python_strings.asp 
- List is a collection which is ordered and changeable. Allows duplicate members.
  Tuple is a collection which is ordered and unchangeable. Allows duplicate members.
  Set is a collection which is unordered and unindexed. No duplicate members.
  Dictionary is a collection which is unordered, changeable and indexed. No duplicate members.
 
   EXAMPLES:
   List : num = [] (or) num = [1,2,3] . 
   append is used add elements. Del is used to del the elements
-  assignmets can be done using =, ?: , single liner if (a = 1 if 20 > 10 else 0)

Condition Controls:
- IF case : if, elif, else are the condition valuators.
Syntax = if(condition):
- Iteration : For loop






Ref: 
https://www.geeksforgeeks.org/python-programming-language/ 
Hacker rank practice