Is python a weakly typed language?

anonymity
Release: 2019-06-15 09:56:45
Original
6582 people have browsed it

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;
Copy after login

javascript code :

3+6
9
"3"+6
"36"
"3"+"6"
"36"
"6"-"3"
3
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template