Python Forum
Is Python strongly or weakly typed?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is Python strongly or weakly typed?
#1
I'm a computers network studant from João Pessoa-Paraiba-Brazil, and I'm studying programming. Python is the programming language that we are atudying and in one of the exams that I made, there was a question saying "Python is strongly typed".

The teacher said this answer was wrong because Python is weakly typed. I believed the teacher, but I'm engaged in my studies, so after some time I decided to search about this and after a lot of search and interaction on forums about Python, I'm almost sure that this is a strongly typed language.

Is Python strongly or weakly typed?
Reply
#2
(Jul-10-2018, 05:31 PM)amandio Wrote: Is Python strongly or weakly typed?
Python is strongly typed.
>>> a = 5
>>> b = '6'
>>> a + b
Traceback (most recent call last):
  File "<string>", line 428, in runcode
  File "<interactive input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
To read more about it:
Why is Python a dynamic language and also a strongly typed language
Reply
#3
Let's make a collection of TypeError, ValueError, InvalidOperation, etc.

In [68]: int('0.3')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-68-0d64588ae80e> in <module>()
----> 1 int('0.3')

ValueError: invalid literal for int() with base 10: '0.3'
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#4
I asked the same question to Guido ... the answer follows in the image..
[Image: resposta1.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't stop keyboard listener to grab chars typed inside CTk window Valjean 9 1,373 Sep-25-2023, 08:07 PM
Last Post: deanhystad
  eliminating letters when typed in python window deebo 0 1,747 Jan-05-2021, 09:26 AM
Last Post: deebo
  ReferenceError: weakly-referenced object no longer exists MrBitPythoner 17 11,578 Dec-14-2020, 07:34 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020