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
232 changes: 209 additions & 23 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,72 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[1,\n",
" 2,\n",
" 3,\n",
" 4,\n",
" 5,\n",
" 6,\n",
" 7,\n",
" 8,\n",
" 9,\n",
" 10,\n",
" 11,\n",
" 12,\n",
" 13,\n",
" 14,\n",
" 15,\n",
" 16,\n",
" 17,\n",
" 18,\n",
" 19,\n",
" 20,\n",
" 21,\n",
" 22,\n",
" 23,\n",
" 24,\n",
" 25,\n",
" 26,\n",
" 27,\n",
" 28,\n",
" 29,\n",
" 30,\n",
" 31,\n",
" 32,\n",
" 33,\n",
" 34,\n",
" 35,\n",
" 36,\n",
" 37,\n",
" 38,\n",
" 39,\n",
" 40,\n",
" 41,\n",
" 42,\n",
" 43,\n",
" 44,\n",
" 45,\n",
" 46,\n",
" 47,\n",
" 48,\n",
" 49]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here "
"# your code here \n",
"integers = range(1, 50)\n",
"list(integers)"
]
},
{
Expand All @@ -43,11 +104,26 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"outputs": [],
"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, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500]\n"
]
}
],
"source": [
"# your code here "
"# your code here \n",
"even_ints = []\n",
"ints = range(1, 501)\n",
"for number in ints:\n",
" if number % 2 == 0:\n",
" even_ints.append(number)\n",
" \n",
"print(even_ints)"
]
},
{
Expand All @@ -59,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -77,11 +153,26 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 10,
"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 "
"# your code here \n",
"ten_by_4 = []\n",
"\n",
"for elem in a:\n",
" for i in elem:\n",
" ten_by_4.append(i)\n",
" \n",
"print(ten_by_4)"
]
},
{
Expand All @@ -93,11 +184,27 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 11,
"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",
"above_pointfive = []\n",
"\n",
"for elem in ten_by_4:\n",
" if elem >= 0.5:\n",
" above_pointfive.append(elem)\n",
" \n",
"print(above_pointfive)\n",
" "
]
},
{
Expand All @@ -109,7 +216,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -131,11 +238,27 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 17,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.55867166, 0.06210792, 0.08147297, 0.82579068, 0.91512478, 0.06833034, 0.05440634, 0.65857693, 0.30296619, 0.06769833, 0.96031863, 0.51293743, 0.09143215, 0.71893382, 0.45850679, 0.58256464, 0.59005654, 0.56266457, 0.71600294, 0.87392666, 0.11434044, 0.8694668, 0.65669313, 0.10708681, 0.07529684, 0.46470767, 0.47984544, 0.65368638, 0.14901286, 0.23760688]\n"
]
}
],
"source": [
"# your code here "
"# your code here \n",
"bigger_list = []\n",
"\n",
"for elem in b:\n",
" for elems in elem:\n",
" for i in elems:\n",
" bigger_list.append(i)\n",
" \n",
"print(bigger_list)"
]
},
{
Expand All @@ -147,11 +270,28 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 16,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0.55867166, 0.82579068, 0.91512478, 0.65857693, 0.96031863, 0.51293743, 0.71893382, 0.58256464, 0.59005654, 0.56266457, 0.71600294, 0.87392666, 0.8694668, 0.65669313, 0.65368638]\n"
]
}
],
"source": [
"# your code here "
"# your code here \n",
"big_above_pointfive = []\n",
"\n",
"for elem in b:\n",
" for elems in elem:\n",
" for i in elems:\n",
" if i >= 0.5:\n",
" big_above_pointfive.append(i)\n",
" \n",
"print(big_above_pointfive)"
]
},
{
Expand All @@ -163,11 +303,57 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"# your code here "
"import os"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"C:\\Users\\Erik\\ErikRepo\\Week1\\day5\\lab-list-comprehensions\\your-code\n"
]
}
],
"source": [
"print(os.getcwd())"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"ename": "FileNotFoundError",
"evalue": "[WinError 3] El sistema no puede encontrar la ruta especificada: '\\\\lab-list-comprehensions\\\\data\\\\'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-38-d80519d6aca0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mcsvfiles\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mfile\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlistdir\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 6\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mfile\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mendswith\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'.csv'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mcsvfiles\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfile\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mFileNotFoundError\u001b[0m: [WinError 3] El sistema no puede encontrar la ruta especificada: '\\\\lab-list-comprehensions\\\\data\\\\'"
]
}
],
"source": [
"# your code here \n",
"path = '\\\\lab-list-comprehensions\\\\data\\\\'\n",
"csvfiles = []\n",
"\n",
"for file in os.listdir(path):\n",
" if file.endswith('.csv'):\n",
" csvfiles.append(file)\n",
" \n",
"print(csvfiles)"
]
},
{
Expand Down Expand Up @@ -313,7 +499,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.8.6"
}
},
"nbformat": 4,
Expand Down