Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indicate that python is zero indexing #5

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 00-Python Object and Data Structure Basics/04-Lists.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}
],
"source": [
"# Grab element at index 0\n",
"# Grab element at index 0 -- python is a zero index programming language\n",
"my_list[0]"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
116 changes: 109 additions & 7 deletions 02-Python Statements/02-if, elif, and else Statements.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To control the flow of logic:\n",
" use\n",
" 1- if\n",
" 2- elif\n",
" 3- else"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -49,10 +60,98 @@
}
],
"source": [
"#if and elif: need condition but else doesn't need condition\n",
"#if -else-elif used to control flow\n",
"#if the dog is hunger: go to feed\n",
"if True:\n",
" print('It was true!')"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's true!!\n"
]
}
],
"source": [
"if True:\n",
" print (\"It's true!!\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True!!\n"
]
}
],
"source": [
"if 3>2:\n",
" print ('True!!')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I am hungery .. Feed me!\n"
]
}
],
"source": [
"hungery = True\n",
"\n",
"if hungery:\n",
" print ('I am hungery .. Feed me!')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I am not hungery\n"
]
}
],
"source": [
"hungery = False\n",
"\n",
"if hungery:\n",
" print ('Feed me!!')\n",
"else:\n",
" print('I am not hungery')"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -97,24 +196,27 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome to the bank!\n"
"Welcome to the store!\n"
]
}
],
"source": [
"loc = 'Bank'\n",
"# elif: check multiple conditions\n",
"loc = 'Store'\n",
"\n",
"if loc == 'Auto Shop':\n",
" print('Welcome to the Auto Shop!')\n",
"elif loc == 'Bank':\n",
" print('Welcome to the bank!')\n",
"elif loc =='Store':\n",
" print('Welcome to the store!')\n",
"else:\n",
" print('Where are you?')"
]
Expand Down Expand Up @@ -152,19 +254,19 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome George!\n"
"Welcome, what's your name?\n"
]
}
],
"source": [
"person = 'George'\n",
"person = 'Abdel'\n",
"\n",
"if person == 'Sammy':\n",
" print('Welcome Sammy!')\n",
Expand Down Expand Up @@ -200,7 +302,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
Loading