Home >Backend Development >Python Tutorial >Is python a weakly typed language?

Is python a weakly typed language?

anonymity
anonymityOriginal
2019-06-15 09:56:456629browse

Is python a weakly typed language? No, Python is a strongly typed dynamic scripting language

Strong type: does not allow the addition of different types

Dynamic: does not use explicit data to declare the type, and determines the value of a variable The type is when it is assigned a value for the first time

Script language: It is generally an interpreted language. Running the code only requires an interpreter and does not require compilation

Is python a weakly typed language?

Here is a comparison between strong typing and weak typing:

python code:

>>> 3+6
9
>>> "3"+6
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can&#39;t convert &#39;int&#39; object to str implicitly
>>> "3"+"6"
&#39;36&#39;
>>> "6"-"3"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: &#39;str&#39; and &#39;str&#39;

javascript code :

3+6
9
"3"+6
"36"
"3"+"6"
"36"
"6"-"3"
3

The above is the detailed content of Is python a weakly typed language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn