
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Why Python is called Dynamically Typed?
Python is a dynamically typed language. What is dynamic? We don't have to declare the type of a variable or manage the memory while assigning a value to a variable in Python. Other languages like C, C++, Java, etc.., there is a strict declaration of variables before assigning values to them. We have to declare the kind of variable before assigning a value to it in the languages C, C++, Java, etc..,
Python don't have any problem even if we don't declare the type of variable. It states the kind of variable in the runtime of the program. Python also take cares of the memory management which is crucial in programming. So, Python is a dynamically typed language. Let's see one example.
Example
## assigning a value to a variable x = [1, 2, 3] ## x is a list here print(type(x)) ## reassigning a value to the 'x' x = True ## x is a bool here print(type(x)) ## we can also redefine 'x' as many times as we want
Output
If you run the above program, it will generate the following results.
<class 'list'> <class 'bool'>
As you see, we didn't declare the type of variable in the program. Python will automatically recognize the type of variable with the help of the value in the runtime.
- Related Articles
- Is Python Dynamically Typed Language?
- Greatest number in a dynamically typed array in JavaScript
- What are the differences between “untyped” & “dynamically typed” programming languages?
- Why is JavaScript considered a loosely-typed language
- Why is __init__() always called after __new__() in python?
- Why is poison ivy is called so?
- Why is javascript called Richer Interface?
- Why is a smartphone called smart?
- Why is petroleum called black gold?
- Why JavaScript is called Richer Interface?
- Why is CNG called as clean fuel?
- Why Naïve Bayesian is classifications called Naïve?
- Why Earth is called a unique Planet?
- Why milk is called a complete food?
- Why eye lens is called crystalline lens?
