Is Python strongly typed

0 votes
I read that Python is a strongly typed language. I thought that such languages couldn't accept type-changing at run-time. But it accepts type changing at run time.
So is Python a strongly or weakly typed language?
Apr 26 in Python by Kichu
• 19,040 points
128 views

1 answer to this question.

0 votes

Python is both strongly and dynamically typed.

Strongly typed: type of value doesn't change in unexpected ways. A string containing only digits doesn't magically become a number, as may happen in Perl. Every change of type requires an explicit conversion.
Dynamically typed: Runtime objects (values) have a type instead of static typing where variables have a type.


The example you mentioned works because the variable does not have a type; it can name any object. After bob=1, you'll find that type(bob) returns an int, but after bob="bob", it returns str. (Note that type is a regular function, so it evaluates its argument, then returns the type of the value.

answered Apr 28 by narikkadan
• 37,660 points

Related Questions In Python

+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
3,330 views
+4 votes
7 answers
0 votes
3 answers

What is python? Where it is used?

 Python is develop by Guido Van Rossum ...READ MORE

answered Mar 18, 2019 in Python by rajesh kumar
375 views
+1 vote
7 answers
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 3,130 views
0 votes
1 answer
0 votes
1 answer

What is the difference between read() and readline() in python?

The read() will read the whole file at ...READ MORE

answered Apr 28 in Python by narikkadan
• 37,660 points
2,391 views
0 votes
1 answer

Error: 'int' object is not subscriptable - Python

The issue is in the line: int([x[age1]]) The solution ...READ MORE

answered Apr 30 in Python by narikkadan
• 37,660 points
828 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP