Skip to content
Open
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
201 changes: 173 additions & 28 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# your code here "
"# your code here \n",
"\n",
"numbers = range (1,50)\n",
"\n"
]
},
{
Expand All @@ -43,11 +46,42 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199]\n"
]
}
],
"source": [
"# your code here "
"# your code here \n",
"\n",
"\n",
"lst=[i for i in range(2,200)]\n",
"print(lst)\n"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176 178 180 182 184 186 188 190 192 194 196 198 "
]
}
],
"source": [
"for num in lst:\n",
" if num % 2 == 0:\n",
" print(num, end= \" \")"
]
},
{
Expand All @@ -59,7 +93,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -77,11 +111,23 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 48,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.84062117, 0.48006452, 0.7876326, 0.77109654, 0.44409793, 0.09014516, 0.81835917, 0.87645456, 0.7066597, 0.09610873, 0.41247947, 0.57433389, 0.29960807, 0.42315023, 0.34452557, 0.4751035, 0.17003563, 0.46843998, 0.92796258, 0.69814654, 0.41290051, 0.19561071, 0.16284783, 0.97016248, 0.71725408, 0.87702738, 0.31244595, 0.76615487, 0.20754036, 0.57871812, 0.07214068, 0.40356048, 0.12149553, 0.53222417, 0.9976855, 0.12536346, 0.80930099, 0.50962849, 0.94555126, 0.33364763]\n"
]
}
],
"source": [
"# your code here "
"# list1 = [i for i in a ]\n",
"# print(list1)\n",
"\n",
"list1 = [j for i in a for j in i ]\n",
"print(list1)"
]
},
{
Expand All @@ -93,11 +139,25 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 46,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.84062117, 0.7876326, 0.77109654, 0.81835917, 0.87645456, 0.7066597, 0.57433389, 0.92796258, 0.69814654, 0.97016248, 0.71725408, 0.87702738, 0.76615487, 0.57871812, 0.53222417, 0.9976855, 0.80930099, 0.50962849, 0.94555126]\n"
]
}
],
"source": [
"# your code here "
"# your code here \n",
"\n",
"# a = [j for i in list_of_lists for j in i]\n",
"\n",
"list2=[j for i in a for j in i if j >= 0.5]\n",
" \n",
"print(list2)"
]
},
{
Expand All @@ -109,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -131,11 +191,40 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 56,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[0.55867166, 0.06210792, 0.08147297], [0.55867166, 0.06210792, 0.08147297], [0.55867166, 0.06210792, 0.08147297], [0.82579068, 0.91512478, 0.06833034], [0.82579068, 0.91512478, 0.06833034], [0.82579068, 0.91512478, 0.06833034], [0.05440634, 0.65857693, 0.30296619], [0.05440634, 0.65857693, 0.30296619], [0.05440634, 0.65857693, 0.30296619], [0.06769833, 0.96031863, 0.51293743], [0.06769833, 0.96031863, 0.51293743], [0.06769833, 0.96031863, 0.51293743], [0.09143215, 0.71893382, 0.45850679], [0.09143215, 0.71893382, 0.45850679], [0.09143215, 0.71893382, 0.45850679], [0.58256464, 0.59005654, 0.56266457], [0.58256464, 0.59005654, 0.56266457], [0.58256464, 0.59005654, 0.56266457], [0.71600294, 0.87392666, 0.11434044], [0.71600294, 0.87392666, 0.11434044], [0.71600294, 0.87392666, 0.11434044], [0.8694668, 0.65669313, 0.10708681], [0.8694668, 0.65669313, 0.10708681], [0.8694668, 0.65669313, 0.10708681], [0.07529684, 0.46470767, 0.47984544], [0.07529684, 0.46470767, 0.47984544], [0.07529684, 0.46470767, 0.47984544], [0.65368638, 0.14901286, 0.23760688], [0.65368638, 0.14901286, 0.23760688], [0.65368638, 0.14901286, 0.23760688]]\n"
]
}
],
"source": [
"# your code here \n",
"\n",
"list3=[j for i in b for j in i for c in j ]\n",
"print(list3)"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.55867166, 0.06210792, 0.08147297, 0.55867166, 0.06210792, 0.08147297, 0.55867166, 0.06210792, 0.08147297, 0.82579068, 0.91512478, 0.06833034, 0.82579068, 0.91512478, 0.06833034, 0.82579068, 0.91512478, 0.06833034, 0.05440634, 0.65857693, 0.30296619, 0.05440634, 0.65857693, 0.30296619, 0.05440634, 0.65857693, 0.30296619, 0.06769833, 0.96031863, 0.51293743, 0.06769833, 0.96031863, 0.51293743, 0.06769833, 0.96031863, 0.51293743, 0.09143215, 0.71893382, 0.45850679, 0.09143215, 0.71893382, 0.45850679, 0.09143215, 0.71893382, 0.45850679, 0.58256464, 0.59005654, 0.56266457, 0.58256464, 0.59005654, 0.56266457, 0.58256464, 0.59005654, 0.56266457, 0.71600294, 0.87392666, 0.11434044, 0.71600294, 0.87392666, 0.11434044, 0.71600294, 0.87392666, 0.11434044, 0.8694668, 0.65669313, 0.10708681, 0.8694668, 0.65669313, 0.10708681, 0.8694668, 0.65669313, 0.10708681, 0.07529684, 0.46470767, 0.47984544, 0.07529684, 0.46470767, 0.47984544, 0.07529684, 0.46470767, 0.47984544, 0.65368638, 0.14901286, 0.23760688, 0.65368638, 0.14901286, 0.23760688, 0.65368638, 0.14901286, 0.23760688]\n"
]
}
],
"source": [
"# your code here "
"list4= [j for i in [j for i in b for j in i for c in j ] for j in i]\n",
"print(list4)"
]
},
{
Expand All @@ -147,11 +236,22 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 61,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.06210792, 0.08147297, 0.06210792, 0.08147297, 0.06210792, 0.08147297, 0.06833034, 0.06833034, 0.06833034, 0.05440634, 0.30296619, 0.05440634, 0.30296619, 0.05440634, 0.30296619, 0.06769833, 0.06769833, 0.06769833, 0.09143215, 0.45850679, 0.09143215, 0.45850679, 0.09143215, 0.45850679, 0.11434044, 0.11434044, 0.11434044, 0.10708681, 0.10708681, 0.10708681, 0.07529684, 0.46470767, 0.47984544, 0.07529684, 0.46470767, 0.47984544, 0.07529684, 0.46470767, 0.47984544, 0.14901286, 0.23760688, 0.14901286, 0.23760688, 0.14901286, 0.23760688]\n"
]
}
],
"source": [
"# your code here "
"# your code here \n",
"\n",
"list5 = [i for i in list4 if i <= 0.5]\n",
"print(list5)"
]
},
{
Expand All @@ -163,11 +263,25 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 66,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['sample_file_1.csv', 'sample_file_0.csv', 'sample_file_2.csv', 'sample_file_3.csv', 'sample_file_7.csv', 'sample_file_6.csv', 'sample_file_4.csv', 'sample_file_5.csv', 'sample_file_8.csv', 'sample_file_9.csv']\n"
]
}
],
"source": [
"# your code here "
"# your code here \n",
"\n",
"import os\n",
"all_files = os.listdir('../data')\n",
"\n",
"files = [i for i in all_files if i.endswith(\".csv\")]\n",
"print(files)"
]
},
{
Expand Down Expand Up @@ -196,21 +310,52 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 85,
"metadata": {},
"outputs": [],
"source": [
"fruits = ['bananas', 'ice-cream', 'carrots', 'cookies', 'guanciale', 'pasta']\n",
"quantities = [2, 1, 5, 9, 7, 2]"
"quantities = [2, 1, 5, 9, 7, 2]\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 86,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Bananas', 'Ice-Cream', 'Carrots', 'Cookies', 'Guanciale', 'Pasta']\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"fruits = [fruit.title() for fruit in fruits]\n",
"print(fruits)"
]
},
{
"cell_type": "code",
"execution_count": 88,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Bananas': 2, 'Ice-Cream': 1, 'Carrots': 5, 'Cookies': 9, 'Guanciale': 7, 'Pasta': 2}\n"
]
}
],
"source": [
"shopping_dict={}\n",
"\n",
"shopping_dict = dict(zip(fruits, quantities))\n",
"\n",
"print(shopping_dict)"
]
},
{
Expand Down Expand Up @@ -313,7 +458,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.6"
}
},
"nbformat": 4,
Expand Down