Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
drchrisliu committed Mar 15, 2019
1 parent 0b3f05d commit cf7c95d
Showing 1 changed file with 142 additions and 1 deletion.
143 changes: 142 additions & 1 deletion python_basic_data_type.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name": "python-basic-data-type.ipynb",
"version": "0.3.2",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
Expand Down Expand Up @@ -59,10 +60,150 @@
},
"cell_type": "code",
"source": [
""
"dog_name = 'Freddie'\n",
"\n",
"age = 9\n",
"\n",
"is_vaccinated = True\n",
"\n",
"height = 1.1\n",
"\n",
"birth_year = 2001"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "4wzs2ANP7in9",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"*Note: we could have done this one per cell. But this all-in-one solution was easier and more elegant.*\n",
"\n",
"From now on, if we type these variables, the assigned values will be returned:"
]
},
{
"metadata": {
"id": "RzUf7o_97otl",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "f34c3748-1acb-4d7f-ee89-ea54cfefccef"
},
"cell_type": "code",
"source": [
"dog_name"
],
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'Freddie'"
]
},
"metadata": {
"tags": []
},
"execution_count": 2
}
]
},
{
"metadata": {
"id": "Q_WLV7Ua7zyd",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "1a994bbc-b8c4-4a6e-a07a-3be8bfc255ca"
},
"cell_type": "code",
"source": [
"age"
],
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"9"
]
},
"metadata": {
"tags": []
},
"execution_count": 3
}
]
},
{
"metadata": {
"id": "F1JncQa1771t",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"Just like in SQL, in Python we have different data types.\n",
"\n",
"\n",
"For instance the dog_name variable holds a string: 'Freddie'. In Python 3 a string is a sequence of Unicode characters (eg. numbers, letters, punctuation, etc.), so it can have numbers or exclamation marks or almost anything (eg. ‘R2-D2’ is a valid string). In Python it’s super easy to identify a string as it’s usually between quotation marks.\n",
"\n",
"The age and the birth_year variables store integers (9 and 2001), which is a numeric Python data type. Another numeric data type is float, in our example: height, which is 1.1.\n",
"\n",
"The is_vaccinated’s True value is a so called Boolean value. Booleans can be only True or False."
]
},
{
"metadata": {
"id": "blRNVueg8HRN",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"dog_name = 'Eddie'"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "5b4VtE_N8K59",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"outputId": "4b349b31-78e8-4d9a-c108-de850c6992bb"
},
"cell_type": "code",
"source": [
"dog_name"
],
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'Eddie'"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
}
]
}

0 comments on commit cf7c95d

Please sign in to comment.