print(type(3.4))
<class 'float'>
print(type(1/3))
<class 'float'>
print(type(4/4))
<class 'float'>
Possible answers to the questions are:
7.25
, float
7.25
, float
, (In Python 3 the whole calculation is treated as floating point irrespective of the order of the values)1
, int
, the calculation is performed as floating point (in Python 3) and then converted to an integer
ValueError: invalid literal for int() with base 10: '3.4'
string
to integer
unless the string
is an 'integer'.3
, int
float
and then to an integer
.3
, int
ValueError: could not convert string to float: 'Hello World!'
1 and 4 give the result 2.0. The complete results should be:
2.0
2.1
ValueError: invalid literal for int() with base 10: '1.1'
2.0
2
TypeError: can't multiply sequence by non-int of type 'float'