diff --git a/StandardLibrary_C++.ipynb b/StandardLibrary_C++.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..4f232a28caad4d30f13a157461c638cc1fa1839a --- /dev/null +++ b/StandardLibrary_C++.ipynb @@ -0,0 +1,308 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "fc73d74c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('answercheck.py', <http.client.HTTPMessage at 0x7fd334327910>)" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "##ANSWER##\n", + "#Install answercheck in current director\n", + "from urllib.request import urlretrieve\n", + "urlretrieve('https://raw.githubusercontent.com/colbrydi/jupytercheck/master/answercheck.py', filename='answercheck.py')\n", + "##ANSWER##" + ] + }, + { + "cell_type": "markdown", + "id": "3c2a4f39", + "metadata": {}, + "source": [ + "# C++ Standard Library\n", + "\n", + "Allows us to store and manipulate data. The overarching library of C++" + ] + }, + { + "cell_type": "markdown", + "id": "71e867d9", + "metadata": {}, + "source": [ + "## Description\n", + "This is a broad library. As with any library (programming or not), it contains many topics with their own information. You will learn more about each of these parts and their implementation later. In the mean time, understand the Standard Library contains the following components:\n", + "- Algorithms \n", + " - including Functions\n", + "- Containers\n", + "- Iterators\n", + "\n", + "This contains other, niche libraries within it. Just like in Python how you need to import packages, in C++ you need to import libraries.\n", + "- Python Importation example:\n", + " - import pandas as pd\n", + "- C++ Importation example:\n", + " - #include <vector.>" + ] + }, + { + "cell_type": "markdown", + "id": "b2ddba57", + "metadata": {}, + "source": [ + "**Note on Naming Convention** <br/>\n", + "\n", + "You may hear the Standard Template Library, aka STL, used interchangeably with the C++ Standard Library. While these are technically not the same thing, it is beyond the scope of this content. Note that often in C++ you use **std::somethinghere**, for example: \n", + "``` bash\n", + " std::vector \n", + " std::string\n", + "```\n", + "the STD stands for **ST**andar**D** library. That is why STD is used instead of STL - again, beyond the scope of this content but now you know why STD is used in front of these statements." + ] + }, + { + "cell_type": "markdown", + "id": "58ec20e8", + "metadata": {}, + "source": [ + "## Self Assessment\n", + "\n", + "Questions that test for the learning goals and allows students to evaluate if they truly understand the topics." + ] + }, + { + "cell_type": "markdown", + "id": "4af35ce7", + "metadata": {}, + "source": [ + "✅ **<span style=\"color:red\">Question 1:</span>** Of the three parts that make up the library (container, algorithm, iterator), which would be used to loop through a vector, like a for-loop would do?\n", + "1. container\n", + "2. algorithm\n", + "3. iterator" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "15f43828", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "##ANSWER##\n", + "3\n", + "##ANSWER##" + ] + }, + { + "cell_type": "markdown", + "id": "3921c156", + "metadata": {}, + "source": [ + "✅ **<span style=\"color:red\">Question 2:</span>** Which of the following would a vector be an example of?\n", + "\n", + "1. container\n", + "2. algorithm\n", + "3. iterator" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "c3dfd97d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "##ANSWER##\n", + "1\n", + "##ANSWER##" + ] + }, + { + "cell_type": "markdown", + "id": "975f2784", + "metadata": {}, + "source": [ + "✅ **<span style=\"color:red\">Question 3:</span>** Which of the following would a contain a function to reverse the values of a vector?\n", + "\n", + "1. container\n", + "2. algorithm\n", + "3. iterator" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "77e8e9d9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "##ANSWER##\n", + "2\n", + "##ANSWER##" + ] + }, + { + "cell_type": "markdown", + "id": "369d2119", + "metadata": {}, + "source": [ + "✅ **<span style=\"color:red\">Question 4:</span>** Which of the following would a for-loop be classified under?\n", + "\n", + "1. container\n", + "2. algorithm\n", + "3. iterator" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "44341f6a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "##ANSWER##\n", + "2\n", + "##ANSWER##" + ] + }, + { + "cell_type": "markdown", + "id": "2a3fad10", + "metadata": {}, + "source": [ + "## Training Materials" + ] + }, + { + "cell_type": "markdown", + "id": "ea15c34b", + "metadata": {}, + "source": [ + "#### Introduction to the Standard Library and Primary Makeup" + ] + }, + { + "cell_type": "markdown", + "id": "343e3b11", + "metadata": {}, + "source": [ + "✅ **<span style=\"color:red\">Read the following website:</span>** https://www.softwaretestinghelp.com/standard-template-library-stl/\n", + "<br/>\n", + "**Note:** You do not need to know everything in this website but your takeaways should be the following:\n", + "- Understand WHAT a container, algorithm and iterator are\n", + "- Understand what they DO\n", + "- You do not need to know the types of each (yet) but it is good to read through and famiiliarize yourself with them because they may be used in the future" + ] + }, + { + "cell_type": "markdown", + "id": "b44650dd", + "metadata": {}, + "source": [ + "#### Other libraries within the Standard Library" + ] + }, + { + "cell_type": "markdown", + "id": "e49bda54", + "metadata": {}, + "source": [ + "✅ **<span style=\"color:red\">Read the following website:</span>** https://en.cppreference.com/w/cpp/header <br/>\n", + "**Note:** Some of the names of the headers should be familiar to you! Keep this in mind when studying - you are not starting from scratch but can infer some information already.\n", + "- Vector\n", + "- String\n", + "- Random\n", + "- Cmath \n", + "<br/> <br/>\n", + "You will only use a fraction of these libraries in your coursework but it is good to see how they are organized." + ] + }, + { + "cell_type": "markdown", + "id": "44b461a0", + "metadata": {}, + "source": [ + "---\n", + "\n", + "Written by Jessica Parks, Michigan State University \n", + "As part of the Data Science Bridge Project \n", + " \n", + "<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc/4.0/88x31.png\" /></a><br />This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\">Creative Commons Attribution-NonCommercial 4.0 International License</a>." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}