Skip to content

Commit 34a1684

Browse files
committed
add comment on division operator py3 vs py2
since these are lecture notes, and the students hear about python for the first time (supposedly), it is very likely that they will use python 3 if the instructor is using python 3. however, some of them might soon find themselves working on some remote system which only has some python 2.x available. therefore, my note.
1 parent 00eda46 commit 34a1684

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎Lecture-1-Introduction-to-Python-Programming.ipynb‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,15 @@
10971097
],
10981098
"prompt_number": 37
10991099
},
1100+
{
1101+
"cell_type": "markdown",
1102+
"metadata": {},
1103+
"source": [
1104+
"Note: The `/` operator always performs a floating point division in Python 3.x.\n",
1105+
"This is not true in Python 2.x, where the result of `/` is always an integer if the operands are integers.\n",
1106+
"to be more specific, `1/2 = 0.5` (`float`) in Python 3.x, and `1/2 = 0` (`int`) in Python 2.x (but `1.0/2 = 0.5` in Python 2.x)."
1107+
]
1108+
},
11001109
{
11011110
"cell_type": "markdown",
11021111
"metadata": {},

0 commit comments

Comments
 (0)