Coding challenges on what is computation?

Problem 1Objects, Types, and Type Casting

Truncate vs Round a Price

Assume you are given a float variable named price_float containing 19.99. Create two new integer variables:

  • price_int_truncated: the integer obtained by chopping off everything after the decimal point (toward zero).
  • price_int_rounded: the integer obtained by rounding price_float to the nearest whole number.

For this input, the two integers should NOT be equal.

Scratchpad— run any Python to test ideas
Python runtime ready in a moment
Python runtime ready in a moment
Visible tests · 2Examples — click to expand
price_int_truncated equals 19
price_int_rounded equals 20
Hidden tests · 3Bodies hidden — pass/fail only
Hidden test 1
Hidden test 2
Hidden test 3