- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
## 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
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.
- Is Python Dynamically Typed Language?
- Why is petroleum called black gold?
- Why is a smartphone called smart?
- Why is __init__() always called after __new__() in python?
- Why is CNG called as clean fuel?
- Which herb is called a magical herb and why?
- Why is Napoleon Bonaparte called a Great War strategist?
- Why is Greenland called as island and not a continent?
- Why are TV serials called daily soaps?
- Why is Greenland called as an island and not a continent?
- Why Naïve Bayesian is classifications called Naïve?
- Why are South Africans called ‘Protease’?
- Which city of India is called the city of dreams and why?