Skip to content

Commit af75449

Browse files
committed
Else again
1 parent 29f0c0e commit af75449

2 files changed

Lines changed: 90 additions & 144 deletions

File tree

Python_Basics/Intro/.ipynb_checkpoints/Python3Basics_Part1-checkpoint.ipynb

Lines changed: 45 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -847,28 +847,18 @@
847847
},
848848
{
849849
"cell_type": "code",
850-
"execution_count": 21,
850+
"execution_count": 9,
851851
"metadata": {},
852-
"outputs": [
853-
{
854-
"data": {
855-
"text/plain": [
856-
"False"
857-
]
858-
},
859-
"execution_count": 21,
860-
"metadata": {},
861-
"output_type": "execute_result"
862-
}
863-
],
852+
"outputs": [],
864853
"source": [
865854
"num = 1\n",
866-
"num > 3"
855+
"if num > 3 :\n",
856+
" print(\"Hi\")"
867857
]
868858
},
869859
{
870860
"cell_type": "code",
871-
"execution_count": 4,
861+
"execution_count": 10,
872862
"metadata": {},
873863
"outputs": [
874864
{
@@ -892,7 +882,7 @@
892882
},
893883
{
894884
"cell_type": "code",
895-
"execution_count": 5,
885+
"execution_count": 11,
896886
"metadata": {},
897887
"outputs": [
898888
{
@@ -912,19 +902,6 @@
912902
" print(\"number is not greater than 3\")"
913903
]
914904
},
915-
{
916-
"cell_type": "code",
917-
"execution_count": null,
918-
"metadata": {
919-
"collapsed": true
920-
},
921-
"outputs": [],
922-
"source": [
923-
"# Modulo (%)\n",
924-
"# Returns the remainder of the division of the number to the left by the \n",
925-
"# number on its right. "
926-
]
927-
},
928905
{
929906
"cell_type": "markdown",
930907
"metadata": {},
@@ -944,68 +921,64 @@
944921
"cell_type": "markdown",
945922
"metadata": {},
946923
"source": [
947-
"Hint: Any integer that can be divided exactly by 2 is an even number (examples: 2, 4, 6). Any integer that cannot be divided exactly by 2 is an odd number (examples: 1, 3, 5)."
924+
"Hint: Any integer that can be divided exactly by 2 is an even number (examples: 2, 4, 6). Any integer that cannot be divided exactly by 2 is an odd number (examples: 1, 3, 5). Use the modulo operator (%) which returns the remainder of the division of the number to the left by the number on its right. \n"
948925
]
949926
},
950927
{
951928
"cell_type": "code",
952-
"execution_count": 10,
929+
"execution_count": 12,
953930
"metadata": {},
954931
"outputs": [
955932
{
956-
"name": "stdout",
957-
"output_type": "stream",
958-
"text": [
959-
"Your integer is even\n"
960-
]
933+
"data": {
934+
"text/plain": [
935+
"0"
936+
]
937+
},
938+
"execution_count": 12,
939+
"metadata": {},
940+
"output_type": "execute_result"
961941
}
962942
],
963943
"source": [
964-
"my_num = 2\n",
965-
"if my_num % 2 == 0:\n",
966-
" print(\"Your integer is even\")\n",
967-
"else: \n",
968-
" print(\"Your number is odd\")"
944+
"4 % 2 "
969945
]
970946
},
971947
{
972-
"cell_type": "markdown",
973-
"metadata": {},
974-
"source": [
975-
"explanation: Modulo (%) returns the remainder of the division of the number to the left by the number on its right. "
976-
]
948+
"cell_type": "code",
949+
"execution_count": null,
950+
"metadata": {
951+
"collapsed": true
952+
},
953+
"outputs": [],
954+
"source": []
977955
},
978956
{
979957
"cell_type": "code",
980-
"execution_count": 6,
958+
"execution_count": null,
981959
"metadata": {
982960
"collapsed": true
983961
},
984962
"outputs": [],
985-
"source": [
986-
"?type"
987-
]
963+
"source": []
988964
},
989965
{
990966
"cell_type": "code",
991-
"execution_count": 7,
992-
"metadata": {},
993-
"outputs": [
994-
{
995-
"data": {
996-
"text/plain": [
997-
"True"
998-
]
999-
},
1000-
"execution_count": 7,
1001-
"metadata": {},
1002-
"output_type": "execute_result"
1003-
}
1004-
],
1005-
"source": [
1006-
"4 % 2\n",
1007-
"True and True"
1008-
]
967+
"execution_count": null,
968+
"metadata": {
969+
"collapsed": true
970+
},
971+
"outputs": [],
972+
"source": []
973+
},
974+
{
975+
"cell_type": "code",
976+
"execution_count": null,
977+
"metadata": {
978+
"collapsed": true
979+
},
980+
"outputs": [],
981+
"source": []
1009982
},
1010983
{
1011984
"cell_type": "code",
@@ -1016,16 +989,16 @@
1016989
"name": "stdout",
1017990
"output_type": "stream",
1018991
"text": [
1019-
"Your number is most likely odd (assuming it isn't a float)\n"
992+
"Your number is odd\n"
1020993
]
1021994
}
1022995
],
1023996
"source": [
1024997
"my_num = 3\n",
1025-
"if type(my_num) == \"int\" and my_num % 2 == 0:\n",
1026-
" print(\"Your number is even\")\n",
998+
"if my_num % 2 == 0:\n",
999+
" print(\"Your integer is even\")\n",
10271000
"else: \n",
1028-
" print(\"Your number is most likely odd (assuming it isn\\'t a float)\")"
1001+
" print(\"Your integer is odd\")"
10291002
]
10301003
},
10311004
{

Python_Basics/Intro/Python3Basics_Part1.ipynb

Lines changed: 45 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -847,28 +847,18 @@
847847
},
848848
{
849849
"cell_type": "code",
850-
"execution_count": 21,
850+
"execution_count": 9,
851851
"metadata": {},
852-
"outputs": [
853-
{
854-
"data": {
855-
"text/plain": [
856-
"False"
857-
]
858-
},
859-
"execution_count": 21,
860-
"metadata": {},
861-
"output_type": "execute_result"
862-
}
863-
],
852+
"outputs": [],
864853
"source": [
865854
"num = 1\n",
866-
"num > 3"
855+
"if num > 3 :\n",
856+
" print(\"Hi\")"
867857
]
868858
},
869859
{
870860
"cell_type": "code",
871-
"execution_count": 4,
861+
"execution_count": 10,
872862
"metadata": {},
873863
"outputs": [
874864
{
@@ -892,7 +882,7 @@
892882
},
893883
{
894884
"cell_type": "code",
895-
"execution_count": 5,
885+
"execution_count": 11,
896886
"metadata": {},
897887
"outputs": [
898888
{
@@ -912,19 +902,6 @@
912902
" print(\"number is not greater than 3\")"
913903
]
914904
},
915-
{
916-
"cell_type": "code",
917-
"execution_count": null,
918-
"metadata": {
919-
"collapsed": true
920-
},
921-
"outputs": [],
922-
"source": [
923-
"# Modulo (%)\n",
924-
"# Returns the remainder of the division of the number to the left by the \n",
925-
"# number on its right. "
926-
]
927-
},
928905
{
929906
"cell_type": "markdown",
930907
"metadata": {},
@@ -944,68 +921,64 @@
944921
"cell_type": "markdown",
945922
"metadata": {},
946923
"source": [
947-
"Hint: Any integer that can be divided exactly by 2 is an even number (examples: 2, 4, 6). Any integer that cannot be divided exactly by 2 is an odd number (examples: 1, 3, 5)."
924+
"Hint: Any integer that can be divided exactly by 2 is an even number (examples: 2, 4, 6). Any integer that cannot be divided exactly by 2 is an odd number (examples: 1, 3, 5). Use the modulo operator (%) which returns the remainder of the division of the number to the left by the number on its right. \n"
948925
]
949926
},
950927
{
951928
"cell_type": "code",
952-
"execution_count": 10,
929+
"execution_count": 12,
953930
"metadata": {},
954931
"outputs": [
955932
{
956-
"name": "stdout",
957-
"output_type": "stream",
958-
"text": [
959-
"Your integer is even\n"
960-
]
933+
"data": {
934+
"text/plain": [
935+
"0"
936+
]
937+
},
938+
"execution_count": 12,
939+
"metadata": {},
940+
"output_type": "execute_result"
961941
}
962942
],
963943
"source": [
964-
"my_num = 2\n",
965-
"if my_num % 2 == 0:\n",
966-
" print(\"Your integer is even\")\n",
967-
"else: \n",
968-
" print(\"Your number is odd\")"
944+
"4 % 2 "
969945
]
970946
},
971947
{
972-
"cell_type": "markdown",
973-
"metadata": {},
974-
"source": [
975-
"explanation: Modulo (%) returns the remainder of the division of the number to the left by the number on its right. "
976-
]
948+
"cell_type": "code",
949+
"execution_count": null,
950+
"metadata": {
951+
"collapsed": true
952+
},
953+
"outputs": [],
954+
"source": []
977955
},
978956
{
979957
"cell_type": "code",
980-
"execution_count": 6,
958+
"execution_count": null,
981959
"metadata": {
982960
"collapsed": true
983961
},
984962
"outputs": [],
985-
"source": [
986-
"?type"
987-
]
963+
"source": []
988964
},
989965
{
990966
"cell_type": "code",
991-
"execution_count": 7,
992-
"metadata": {},
993-
"outputs": [
994-
{
995-
"data": {
996-
"text/plain": [
997-
"True"
998-
]
999-
},
1000-
"execution_count": 7,
1001-
"metadata": {},
1002-
"output_type": "execute_result"
1003-
}
1004-
],
1005-
"source": [
1006-
"4 % 2\n",
1007-
"True and True"
1008-
]
967+
"execution_count": null,
968+
"metadata": {
969+
"collapsed": true
970+
},
971+
"outputs": [],
972+
"source": []
973+
},
974+
{
975+
"cell_type": "code",
976+
"execution_count": null,
977+
"metadata": {
978+
"collapsed": true
979+
},
980+
"outputs": [],
981+
"source": []
1009982
},
1010983
{
1011984
"cell_type": "code",
@@ -1016,16 +989,16 @@
1016989
"name": "stdout",
1017990
"output_type": "stream",
1018991
"text": [
1019-
"Your number is most likely odd (assuming it isn't a float)\n"
992+
"Your number is odd\n"
1020993
]
1021994
}
1022995
],
1023996
"source": [
1024997
"my_num = 3\n",
1025-
"if type(my_num) == \"int\" and my_num % 2 == 0:\n",
1026-
" print(\"Your number is even\")\n",
998+
"if my_num % 2 == 0:\n",
999+
" print(\"Your integer is even\")\n",
10271000
"else: \n",
1028-
" print(\"Your number is most likely odd (assuming it isn\\'t a float)\")"
1001+
" print(\"Your integer is odd\")"
10291002
]
10301003
},
10311004
{

0 commit comments

Comments
 (0)