Skip to content

Instantly share code, notes, and snippets.

@vishalsingha
Last active January 31, 2021 04:18
Show Gist options
  • Save vishalsingha/9a5bd07434d6f6e9dd2b94da001ac6c4 to your computer and use it in GitHub Desktop.
Save vishalsingha/9a5bd07434d6f6e9dd2b94da001ac6c4 to your computer and use it in GitHub Desktop.
Untitled13.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Untitled13.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyPBXpk0E6oO9nlDTE/vvsr5",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/vishalsingha/9a5bd07434d6f6e9dd2b94da001ac6c4/untitled13.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "-9hzGN-Rex7y",
"outputId": "a3f4cb44-16f9-43dd-a581-1453419abfeb"
},
"source": [
"print('The addition of 15 and 3 is', 15+3)\r\n",
"print('The substraction of 15 and 3 is', 15-3)\r\n",
"print('The multiplication of 15 and 3 is', 2*3)\r\n",
"print('The division of 15 and 4 is', 15/4)\r\n",
"print('The integer division of 15 and 4 is', 15//4)"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"The addition of 15 and 3 is 18\n",
"The substraction of 15 and 3 is 12\n",
"The multiplication of 15 and 3 is 6\n",
"The division of 15 and 4 is 3.75\n",
"The integer division of 15 and 4 is 3\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 178
},
"id": "JyUeMPH7o3iS",
"outputId": "71f65492-874a-401b-ab08-6e60b88f9750"
},
"source": [
"# Division by zero\r\n",
"print('The division of 15 and 4 is', 15/0)"
],
"execution_count": 3,
"outputs": [
{
"output_type": "error",
"ename": "ZeroDivisionError",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-37-15eed18b3da6>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Division by zero\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'The division of 15 and 4 is'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m15\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mZeroDivisionError\u001b[0m: division by zero"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "u-y1ASNtmSNG",
"outputId": "415026c7-25c4-47b8-95e2-ae865bba5e56"
},
"source": [
"print('The of 15 and 4 is', 15%4)\r\n",
"print('The of 15 and 3 is', 15%3)"
],
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"text": [
"The of 15 and 4 is 3\n",
"The of 15 and 3 is 0\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "HkiGoTXCmZEl",
"outputId": "3e3273c5-a7a5-404a-a99f-886c25487c8d"
},
"source": [
"print('5 raised to the power 2 is',5**2)"
],
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"text": [
"5 raised to the power 2 is 25\n"
],
"name": "stdout"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment