Https://www.codecademy.com/courses/learn-python/lessons/python-syntax/exercises/arithmetic?action=resume

I was learning the python2 course and while going through the arithmetic syntax I got stuck here.

Can you please tell me why is it showing 3 as the answer while the correct answer should have been 7/2 or 3.5.

3 Likes

The values are integers so python truncates the result into an integer. Try using
test_one=14.0/2/2 or any variant where one of the numbers is declared as a float.

1 Like

Then why do it changes to 3 but not to 4 ?
Is there any rule applied here ?

1 Like

Also thanks for the help, I tried your suggestion and it worked.
Appreciated man.

After looking at several websites, it seems like Python 2 rounds down. Check out this link:

I hope this helps =)

2 Likes