Tuesday, May 5, 2020

python syntax and style

Python does not require braces ( example curlly braces in the loops/conditions )

example

C/JAVA



Python example 


what is meant by continuation operator ?

x = "hello my name is  "+\
"Tigerkaushik"


In Java, it is something like the block based,

for 

{


}


In python, it is something like the suite ( I mean it is called as the suite 

example : 

: ---> colon 
and proper spacing ( means indentation is very important ).


Python awesome feature,

No need to specify the ; ( semicolon ) at the end of the statement. ( not an mandotory ).

it is only used in this scenario,


Variable assignments ( felt like an interesting topic ).

First feature, 

In runtime, it assumes datatype based on the value.

for example,

a = 10  # integer 

[ Based on the assigned value, it will dynamically assume the datatype and this happends in runtime ]
This kind of languages are called as the dynamic typed languages.  In whatever language, if you dont have the Int, Float etc datatype keywords those languages are called  dynamic typed languages.

other languages : javaScript, php  



more examples 



what is not allowed in python ?


Swapping ( easy to use the swapping thing in python, it does not require additional/temporary variable to store the value and pretty easy to achieve the swapping ).





Identifier is same as the other languages.

Interesting feature is Memory Management 

Supports : Automatic memory management.

Python : No need to declare the variable ahead. Python does not allow expressions.

Note: automatic declare and assignment of value will be happened in runtime.

Memory management ========================================> 

  1.   No need to declare the variables 
  2.   No need to declare the datatypes 
  3.   No burden to the programmer for memory management 
  4.   variables can be recycled 
  5.   Use "del"  to deallocate memory manually 

Python Objects 


Everything we treat as an object.

For example, if you store a value in a variable, that is also considered as an object.







































No comments:

Post a Comment