Back to questions
JuniorTheoryCommon
What does the program print?
print(int(2.9), int("7") + 1, float(3))2 8 3.0
- Expecting
int(2.9)to round to3:int()drops the fractional part, soint(2.9)is2, not the nearest whole number3. - Expecting
71, as if+ 1wrote the digit1after7:int("7")is the number7, and a number plus1is8.
- What does
int("2.5")do, and how would you get2from that string? - What does
print(int(-2.9))print?