Skip to content
Open

Main #45

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
4 changes: 2 additions & 2 deletions activities/1.1-basic-jupyter-notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "f2b4273a",
"metadata": {},
"outputs": [
Expand All @@ -45,7 +45,7 @@
],
"source": [
"# This is a Python code cell\n",
"print('Hello, JupyterLab!')"
"print('Hello Chandrashekhar')"
]
},
{
Expand Down
22 changes: 21 additions & 1 deletion src/1-line-plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,27 @@
"outputs": [],
"source": [
"# TASK: Create a line plot with x values ranging from 0 to 10 and y values as the square of x.\n",
"# Customize the plot by adding a title, labels for both axes, and a grid."
"# Customize the plot by adding a title, labels for both axes, and a grid.\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"# Generate x values from 0 to 10\n",
"x = np.linspace(0, 10, 100)\n",
"\n",
"# Calculate y values as the square of x\n",
"y = x**2\n",
"\n",
"# Create the line plot\n",
"plt.plot(x, y)\n",
"\n",
"# Customize the plot\n",
"plt.title(\"Quadratic Function: y = x^2\")\n",
"plt.xlabel(\"x-axis\")\n",
"plt.ylabel(\"y-axis\")\n",
"plt.grid(True)\n",
"\n",
"# Display the plot\n",
"plt.show()"
]
}
],
Expand Down
21 changes: 20 additions & 1 deletion src/2-bar-plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,26 @@
"outputs": [],
"source": [
"# TASK: Create a bar plot with the following data: categories = ['A', 'B', 'C', 'D'] and values = [5, 7, 3, 9].\n",
"# Use different colors for each bar and add a title to the plot."
"# Use different colors for each bar and add a title to the plot.\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Define data\n",
"categories = ['A', 'B', 'C', 'D']\n",
"values = [5, 7, 3, 9]\n",
"\n",
"# Define colors for each bar\n",
"colors = ['blue', 'green', 'red', 'purple']\n",
"\n",
"# Create the bar plot\n",
"plt.bar(categories, values, color=colors)\n",
"\n",
"# Add title and labels\n",
"plt.title('Bar Plot with Different Colors')\n",
"plt.xlabel('Categories')\n",
"plt.ylabel('Values')\n",
"\n",
"# Show the plot\n",
"plt.show()"
]
}
],
Expand Down
25 changes: 24 additions & 1 deletion src/3-scatter-plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,30 @@
"outputs": [],
"source": [
"# TASK: Create a scatter plot with x = [1, 2, 3, 4, 5] and y = [2, 4, 6, 8, 10].\n",
"# Annotate each point with its (x, y) value, and set the title as 'Scatter Plot with Annotations'."
"# Annotate each point with its (x, y) value, and set the title as 'Scatter Plot with Annotations'.\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Data for the scatter plot\n",
"x = [1, 2, 3, 4, 5]\n",
"y = [2, 4, 6, 8, 10]\n",
"\n",
"# Create the scatter plot\n",
"plt.figure(figsize=(8, 6))\n",
"plt.scatter(x, y, color='blue')\n",
"\n",
"# Annotate each point with its (x, y) value\n",
"for i in range(len(x)):\n",
" plt.annotate(f'({x[i]}, {y[i]})', (x[i], y[i]), textcoords=\"offset points\", xytext=(5,5), ha='left')\n",
"\n",
"# Set the title and labels\n",
"plt.title('Scatter Plot with Annotations')\n",
"plt.xlabel('X-axis')\n",
"plt.ylabel('Y-axis')\n",
"plt.grid(True)\n",
"plt.tight_layout()\n",
"\n",
"# Show the plot\n",
"plt.show()\n"
]
}
],
Expand Down
21 changes: 20 additions & 1 deletion src/4-pie-chart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,26 @@
"outputs": [],
"source": [
"# TASK: Create a pie chart with the following data: labels = ['Python', 'Java', 'C++', 'JavaScript'] and sizes = [40, 25, 20, 15].\n",
"# Display the percentages on the chart using autopct."
"# Display the percentages on the chart using autopct.\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Data for the pie chart\n",
"labels = ['Python', 'Java', 'C++', 'JavaScript']\n",
"sizes = [40, 25, 20, 15]\n",
"\n",
"# Create the pie chart\n",
"plt.figure(figsize=(8, 8))\n",
"plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)\n",
"\n",
"# Set the title\n",
"plt.title('Programming Language Popularity')\n",
"\n",
"# Equal aspect ratio ensures that pie is drawn as a circle\n",
"plt.axis('equal')\n",
"plt.tight_layout()\n",
"\n",
"# Show the plot\n",
"plt.show()\n"
]
}
],
Expand Down
35 changes: 34 additions & 1 deletion src/5-subplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,40 @@
"outputs": [],
"source": [
"# TASK: Create a 2x2 subplot layout.\n",
"# Plot a line chart in the first subplot, a bar chart in the second, a scatter plot in the third, and a pie chart in the fourth."
"# Plot a line chart in the first subplot, a bar chart in the second, a scatter plot in the third, and a pie chart in the fourth.\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Create a 2x2 subplot layout\n",
"fig, axs = plt.subplots(2, 2, figsize=(12, 10))\n",
"\n",
"# Line chart data\n",
"x = [1, 2, 3, 4, 5]\n",
"y = [2, 3, 5, 7, 11]\n",
"axs[0, 0].plot(x, y, marker='o')\n",
"axs[0, 0].set_title('Line Chart')\n",
"\n",
"# Bar chart data\n",
"categories = ['A', 'B', 'C', 'D']\n",
"values = [10, 20, 15, 25]\n",
"axs[0, 1].bar(categories, values, color='skyblue')\n",
"axs[0, 1].set_title('Bar Chart')\n",
"\n",
"# Scatter plot data\n",
"x_scatter = [1, 2, 3, 4, 5]\n",
"y_scatter = [5, 4, 3, 2, 1]\n",
"axs[1, 0].scatter(x_scatter, y_scatter, color='green')\n",
"axs[1, 0].set_title('Scatter Plot')\n",
"\n",
"# Pie chart data\n",
"labels = ['Python', 'Java', 'C++', 'JavaScript']\n",
"sizes = [40, 25, 20, 15]\n",
"axs[1, 1].pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)\n",
"axs[1, 1].set_title('Pie Chart')\n",
"axs[1, 1].axis('equal') # Equal aspect ratio\n",
"\n",
"# Adjust layout\n",
"plt.tight_layout()\n",
"plt.show()\n"
]
}
],
Expand Down
19 changes: 18 additions & 1 deletion src/6-histogram.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@
"outputs": [],
"source": [
"# TASK: Create a histogram for the following data: data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5].\n",
"# Customize the histogram with a title, labels for the x-axis, and a specific color for the bars."
"# Customize the histogram with a title, labels for the x-axis, and a specific color for the bars.\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Data for the histogram\n",
"data = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5]\n",
"\n",
"# Create the histogram\n",
"plt.figure(figsize=(8, 6))\n",
"plt.hist(data, bins=5, color='orange', edgecolor='black')\n",
"\n",
"# Customize with title and axis labels\n",
"plt.title('Histogram of Data')\n",
"plt.xlabel('Value')\n",
"plt.ylabel('Frequency')\n",
"\n",
"plt.grid(True)\n",
"plt.tight_layout()\n",
"plt.show()\n"
]
}
],
Expand Down