0
0
Pythonprogramming~5 mins

Numeric values (int and float behavior) in Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the difference between int and float in Python?

int represents whole numbers without decimals, like 5 or -3.

float represents numbers with decimals, like 3.14 or -0.001.

Click to reveal answer
beginner
What happens when you divide two integers using / in Python?

The result is always a float, even if the division is exact.

Example: 4 / 2 gives 2.0, not 2.

Click to reveal answer
beginner
How can you convert a float to an int in Python?

Use the int() function. It removes the decimal part (truncates).

Example: int(3.9) becomes 3.

Click to reveal answer
beginner
What is the result of int(3.9999) and why?

The result is 3 because int() cuts off the decimal part without rounding.

Click to reveal answer
intermediate
Why can floating point numbers sometimes give unexpected results in calculations?

Because floats are stored in a way that can’t exactly represent some decimal numbers, small rounding errors can happen.

Example: 0.1 + 0.2 might not exactly equal 0.3.

Click to reveal answer
What type does the expression 5 / 2 return in Python?
Abool
Bint
Cstring
Dfloat
What does int(7.8) return?
A7
B8
C7.8
DError
Which of these is a valid float number in Python?
A3
B"3.0"
C3.0
D3,0
What is the output of 0.1 + 0.2 == 0.3 in Python?
ATrue
BFalse
CError
DNone
How do you convert an integer 5 to a float?
Afloat(5)
Bint(5)
Cstr(5)
Dbool(5)
Explain the difference between int and float types in Python and how division behaves with these types.
Think about whole numbers vs numbers with decimals and what happens when you divide.
You got /4 concepts.
    Describe why floating point numbers can cause unexpected results in calculations and how Python stores these numbers.
    Consider how computers store decimal numbers in binary.
    You got /4 concepts.