You are on page 1of 3

{

"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a is less than b\n",
"a is definitely less than b\n",
"Not sure if a is less than b\n"
]
}
],
"source": [
"a = 1\n",
"b = 2\n",
"if a < b:\n",
" print(\"a is less than b\")\n",
" print(\"a is definitely less than b\")\n",
"print(\"Not sure if a is less than b\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"c is NOT less than d\n",
"I don't think c is less than d\n",
"outside the if block\n"
]
}
],
"source": [
"c = 5\n",
"d = 4\n",
"if c < d:\n",
" print(\"c is less than d\")\n",
"else:\n",
" print(\"c is NOT less than d\")\n",
" print(\"I don't think c is less than d\")\n",
"print(\"outside the if block\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"e is greater than f by more than 10\n"
]
}
],
"source": [
"e = 20\n",
"f = 8\n",
"if e < f:\n",
" print(\"e is less than f\")\n",
"elif e == f:\n",
" print(\"e is equal to f\")\n",
"elif e > f + 10:\n",
" print(\"e is greater than f by more than 10\")\n",
"else:\n",
" print(\"e is greater than f\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"g is greater than h\n"
]
}
],
"source": [
"g = 9\n",
"h = 8\n",
"if g < h:\n",
" print(\"g is less than h\")\n",
"else:\n",
" if g == h:\n",
" print(\"g is equal to h\")\n",
" else:\n",
" print(\"g is greater than h\")"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"bmi: \n",
"27.5\n",
"YK\n",
"is overweight\n"
]
}
],
"source": [
"name = \"YK\"\n",
"height_m = 2\n",
"weight_kg = 110\n",
"\n",
"bmi = weight_kg / (height_m ** 2)\n",
"print(\"bmi: \")\n",
"print(bmi)\n",
"if bmi < 25:\n",
" print(name)\n",
" print(\"is not overweight\")\n",
"else:\n",
" print(name)\n",
" print(\"is overweight\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"csdojo.io/pat\n",
"csdojo.io/news\n",
"csdojo.io/python2\n",
"\n",
"YK from CS Dojo"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

You might also like