What is the default value that Python chooses when adding two variables?
<p>Suppose we have the following context: </p>

<pre><code>x = 3  
y = 4  
z = x + y
</code></pre>

<p>Will <code>z</code> be an <code>int</code> or <code>float</code>, etc? I am well aware that floating numbers do end with <code>.something</code>, however its unclear to me whether Python will favour the floating point type over the integer type, given the circumstances that it is unpredictable whether the user is going to change this variable to another type or not.</p>

<p>For example:</p>

<pre><code>&gt;&gt;&gt; type(3 + 4)
&lt;class 'int'&gt;
&gt;&gt;&gt; type(3.0 + 4)
&lt;class 'float'&gt;
&gt;&gt;&gt; type(3.0 + 4.0)
&lt;class 'float'&gt;
</code></pre>

<p>If the difference between a float or integer is important to your application, explicitly convert the user input into a float so you know what you are dealing with every time.</p>

<pre><code>user_input = float(input())
</code></pre>

python python-3.x types