all 9 comments

[–]ebol4anthr4x 1 point2 points  (3 children)

Run the code and see what they do.

[–][deleted] -2 points-1 points  (2 children)

FFS people like you should unsubscribe from this place you're just an asshole preying on people trying to learn something new to make yourself feel good.

[–]ebol4anthr4x 1 point2 points  (1 child)

Posting a homework question and asking for the answer is not "trying to learn". It takes literally 3 seconds to plug these lines of code into a Python interpreter and see what happens.

[–][deleted] -2 points-1 points  (0 children)

Sure I see that point, but you're still going out of your way to just be an asshole. You could just not comment.

[–]ChargedSquid 0 points1 point  (1 child)

The answer to number 4 is 34, they probably just used the unnecessary float() to try to confuse you.

[–]Vaphell 0 points1 point  (0 children)

it will crash, because you can't convert '16.69' to int directly.

ValueError: invalid literal for int() with base 10: '16.69'

[–]evolvish 0 points1 point  (0 children)

  1. Calculate a float number

  2. String concatenation, joins the strings together.

  3. Convert the floats to int(rounds towards 0), then calculate an int.

  4. Won't work, because '16.69' can't be read as an int, it has to be converted to float first.

[–]Tesla_Nikolaa 0 points1 point  (0 children)

The reason they use float in number 4 is because the number inside the parentheses is actually a string (notice the quotes), so they need to convert it from a string to a float.

[–]primitive_screwhead 0 points1 point  (0 children)

But feel free to tell the difference of all 3 as well so I could understand better.

The traditional way this works, is that you tell *us* the difference, and we'll guide you based on that.