{ "cells": [ { "cell_type": "markdown", "id": "d79c7744", "metadata": {}, "source": [ "# Questions:" ] }, { "cell_type": "code", "execution_count": 4, "id": "29390dc7", "metadata": {}, "outputs": [], "source": [ "# 1) Given this array: (3 + 4 points for the following items, total 7 points)\n", "# a)\n", "\n", "arr = np.array([[44, 24, 46, 14, 22, 28, 36, 31, 5, 19, 46, 49, 49, 6, 1],\n", " [ 3, 14, 22, 46, 13, 45, 26, 48, 12, 20, 6, 46, 24, 17, 38],\n", " [35, 13, 31, 5, 25, 47, 1, 4, 0, 19, 20, 40, 28, 49, 39],\n", " [44, 22, 49, 31, 19, 25, 25, 16, 24, 8, 13, 28, 48, 11, 4],\n", " [27, 8, 34, 29, 49, 6, 14, 11, 37, 25, 9, 46, 7, 44, 4],\n", " [39, 48, 19, 44, 9, 23, 33, 18, 45, 23, 42, 49, 37, 21, 32],\n", " [39, 40, 1, 6, 49, 25, 29, 7, 36, 10, 12, 22, 3, 42, 10],\n", " [ 3, 14, 36, 26, 6, 15, 0, 29, 33, 46, 22, 8, 26, 24, 30],\n", " [ 6, 2, 11, 26, 2, 15, 14, 0, 42, 46, 19, 39, 47, 28, 22],\n", " [22, 34, 4, 25, 34, 32, 1, 43, 18, 4, 37, 24, 16, 4, 31],\n", " [15, 32, 42, 38, 17, 43, 41, 20, 31, 8, 33, 38, 13, 39, 26],\n", " [ 3, 15, 15, 5, 26, 32, 26, 45, 23, 2, 33, 49, 49, 10, 32],\n", " [33, 29, 38, 9, 12, 22, 34, 11, 5, 32, 11, 15, 8, 25, 41]])" ] }, { "cell_type": "code", "execution_count": 3, "id": "9f236732", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[41, 20, 31],\n", " [26, 45, 23],\n", " [34, 11, 5]])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# a) What should be written in this box so that the answer appears as shown below?\n", "# Answer: \n" ] }, { "cell_type": "code", "execution_count": null, "id": "8853931c", "metadata": {}, "outputs": [], "source": [ "# b) What are the differences between these 2 methods: linspace and arange?\n", "\n", "\"\"\"\n", "Answer: \n", "\n", "\"\"\"" ] }, { "cell_type": "markdown", "id": "83790b18", "metadata": {}, "source": [ "## 2) Create a random array with 40 elements. Then reshape it into a 3-dimensional array. Print all possible 4D array shapes that can be formed from these elements. (4 points)" ] }, { "cell_type": "code", "execution_count": null, "id": "641f67f6", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "5bf9fce8", "metadata": {}, "source": [ "## 3) Solve this system of equations using NumPy:(6 points)\n", "\n", "\\begin{cases}\n", "-x + 2z + 3t = 7 \\\\\n", "z - y + 4x - 5t = -3 \\\\\n", "3y + 2z + x - 6t = 11 \\\\\n", "4z - y + 2x + t = 8\n", "\\end{cases}" ] }, { "cell_type": "code", "execution_count": null, "id": "48b6e6ac", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "fc404db3", "metadata": {}, "source": [ "## 4) Given the following dataframe. Answer the following questions:(3 points for each item, total 9 points)" ] }, { "cell_type": "code", "execution_count": 8, "id": "32cd5c91", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NameAgeDepartmentMath_ScorePhysics_Score
0Ali19.0CS95.0100.0
1Ayxan20.0Math40.085.0
2Mecnun19.0CS78.075.0
3LeylaNaNPhysics50.032.0
4Nahid21.0MathNaN88.0
5Fatima20.0CS85.0NaN
6Serxan22.0Physics70.048.0
7Aydin19.0CS85.084.0
\n", "
" ], "text/plain": [ " Name Age Department Math_Score Physics_Score\n", "0 Ali 19.0 CS 95.0 100.0\n", "1 Ayxan 20.0 Math 40.0 85.0\n", "2 Mecnun 19.0 CS 78.0 75.0\n", "3 Leyla NaN Physics 50.0 32.0\n", "4 Nahid 21.0 Math NaN 88.0\n", "5 Fatima 20.0 CS 85.0 NaN\n", "6 Serxan 22.0 Physics 70.0 48.0\n", "7 Aydin 19.0 CS 85.0 84.0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data = {\n", " \"Name\": [\"Ali\", \"Ayxan\", \"Mecnun\", \"Leyla\", \"Nahid\", \"Fatima\", \"Serxan\", \"Aydin\"],\n", " \"Age\": [19, 20, 19, np.nan, 21, 20, 22, 19],\n", " \"Department\": [\"CS\", \"Math\", \"CS\", \"Physics\", \"Math\", \"CS\", \"Physics\", \"CS\"],\n", " \"Math_Score\": [95, 40, 78, 50, np.nan, 85, 70, 85],\n", " \"Physics_Score\": [100, 85, 75, 32, 88, np.nan, 48, 84],\n", "}\n", "\n", "df = pd.DataFrame(data)\n", "df" ] }, { "cell_type": "markdown", "id": "ef3bfa75", "metadata": {}, "source": [ "#### a) Display the list of students who failed both Mathematics and Physics:" ] }, { "cell_type": "code", "execution_count": null, "id": "31c0cc27", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "b799c07b", "metadata": {}, "source": [ "#### b) Fill the missing (NaN) values in the Mathematics and Physics score columns with the mean of their respective columns:" ] }, { "cell_type": "code", "execution_count": null, "id": "bba7322b", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "4d97f30b", "metadata": {}, "source": [ "#### c) Determine the maximum Mathematics score in each department:" ] }, { "cell_type": "code", "execution_count": null, "id": "862289b7", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "cc2e45df", "metadata": {}, "source": [ "## 5) Load \"titanic\" dataset from Seaborn and answer the following questions: (3 points for each item, total 9 points)\n", "\n", "#### a) Compare survival rates across Pclass (ticket class, with barplot):" ] }, { "cell_type": "code", "execution_count": null, "id": "b33aceb9", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "e8107c57", "metadata": {}, "source": [ "#### b) Create a scatter plot between age and fare:" ] }, { "cell_type": "code", "execution_count": null, "id": "6ecbd011", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "5ceef60f", "metadata": {}, "source": [ "#### c) Create a visualization of the correlation between all numerical variables:" ] }, { "cell_type": "code", "execution_count": null, "id": "4b214e79", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.14" } }, "nbformat": 4, "nbformat_minor": 5 }