Python Variables don't need to be explicitly declared in advance. These will be created as soon as you use the "=" sign and assign a value to a variable even for the first time This behavior is called "Dynamic". The language is dynamically and implicitly typed. When you assign a value to a variable, it will automatically try to figure out the appropriate type. Standard Data Types in Python are: Numbers, Strings, List, Tuples, Dictionaries. In this example we see, how you don't really have to declare the variables (named radius and name_of_shape) in advance. Also, you can quickly take a look at the Dynamic Typing. Read the code. You don't need to specify the type of x in advance. Detecting the type happens real time, at run time. This creates flexibility for the programmer.This also means, that some semantic checking cannot be done at compile time. And this might lead to unexpected results or errors at Run Time.
Output of the program above: ~/work/pythontutorials$ python DynamicVariablesAndTypes.py Area of Circle=628.3185307179587 Variable radius is passed into guess_type Value passed in:10 A Number was passed in Variable name_of_shape is passed into guess_type: Something else was passed in |