Day 01: Pre-Class Assignment: Welcome to CMSE802#
✅ Put your name here#
Before diving into this exercise#
✅DO THIS: To prepare for this class:
Review the syllabus, be aware of the course goal, contents, and organization.
Outline#
Learning objectives#
For each exercise, you will see a list of learning objectives like these specifying what you should be able to do after.
You should be able to:
Explain what this course is about after reading through the syllabus.
Assess Jupyter notebooks using your computer.
Make changes and run codes in Jupyter notebook.
Integrated Development Environments#
IDEs (Integrated Development Environments) are software applications that provide a comprehensive set of tools and features to facilitate software development. They are designed to enhance productivity and streamline the coding process by combining code editing, debugging, and build automation into a single interface.
IDEs typically include features such as code editors with syntax highlighting, code completion, and code navigation capabilities. They also provide debugging tools to help identify and fix errors in the code. Additionally, IDEs often have built-in support for version control systems, allowing developers to manage their code repositories directly from the IDE.
Some popular IDEs include Visual Studio Code, PyCharm, Eclipse, and IntelliJ IDEA. These IDEs support multiple programming languages and offer a wide range of extensions and plugins to customize the development environment according to the specific needs of the developer.
Using an IDE can greatly improve the efficiency and effectiveness of software development, as it provides a centralized and organized workspace for writing, testing, and debugging code. It helps developers write cleaner and more maintainable code by providing real-time feedback and suggestions, and it simplifies the process of building and deploying applications.
Overall, IDEs are powerful tools that enable developers to write, test, and debug code more efficiently, ultimately enhancing the software development process.
You are free to use any IDE of your choice for this course, as long as it supports the programming languages and tools required. However, in order to maintain consistency and ensure that everyone is on the same page, this course will primarily use Visual Studio Code (VS Code) as the recommended IDE. VS Code offers a wide range of features and extensions that are well-suited for software development. Additionally, if you prefer a notebook-style environment, you can also use Jupyter Lab, which provides a rich interactive coding experience.
Getting started with VS Code#
What is VS Code?#
VS Code is a free, open source, cross-platform integrated development environment with the following features:
Free(-ish): You can use it without cost. But in the license agreement: “The software may collect information about you and your use of the software, and send that to Microsoft… You may opt-out of many of these scenarios, but not all…”
Versatile: It has a very large extension libary that we will use for this class.
Version control: It has support for git and GitHub through extensions.
And many others.
There is a series of other tutorial and documentation on VS Code. Some of them will be used in later parts of the class..
Learn VS Code in 7 min#
✅DO THIS: Watch Learn Visual Studio Code in 7 min video. Once you finish watching, do the following:
Download VS Code from this page,
Install and run it.
Creating the CMSE802 Directory Structure Using VS Code#
Visual Studio Code (VS Code) provides an integrated file explorer that makes it easy to create and manage your directory structure. Follow these steps to set up your CMSE802 folder structure using VS Code:
Open VS Code
Launch Visual Studio Code on your computer.
Open the folder where you want to create your CMSE802 directory
Click on “File” in the top menu, then select “Open Folder”.
Navigate to the location where you want to create your CMSE802 folder (e.g., Documents).
Click the “New Folder” icon that appears.
Type “CMSE802” and press Enter.
Select “Open”
Create subdirectories
In the VS Code Explorer (left sidebar), hover over the CMSE802 folder and click the “New Folder” icon.
Type “Class_Material” and press Enter.
Repeat this process to create a “Reports” folder.
Create subdirectories in Class_Material
Expand the Class_Material folder by clicking the arrow next to it.
Hover over Class_Material and click the “New Folder” icon.
Type “Day01_CourseOverview” and press Enter.
Repeat to create “Day02_CLIAndScripting”.
Create subdirectory in Reports
Expand the Reports folder.
Hover over Reports and click the “New Folder” icon.
Type “Report01_Research_Interests” and press Enter.
Verify your structure
Your VS Code Explorer should now show the following structure:
CMSE802 ├── Class_Material │ ├── Day01_CourseOverview │ └── Day02_CLIAndScripting
Add your first file.
Save and close this notebook and move it into the “Day01_CourseOverview” folder.
Tips for Using VS Code File Explorer#
You can drag and drop folders to rearrange them if needed.
Right-clicking on any folder gives you options to create new files, rename, or delete folders.
The VS Code Explorer provides a clear visual representation of your directory structure, making it easy to navigate and manage your files.
By using VS Code to create your directory structure, you’re also familiarizing yourself with the tool you’ll likely be using for much of your coursework.
Install extension#
✅DO THIS: You will be writing and running Python codes in VS Code. To do this, you need to install the Python extension. To install the Python and Jupyter extensions in VS Code, follow these steps:
Open VS Code and click on the icon with four little boxes on the left sidebar to open the “Extensions” tab.
In the search bar, type “Python” and press Enter.
Look for the “Python” extension in the search results and click on the “Install” button.
After the installation is complete, search for the “Jupyter” extension in the same way and install it as well.
Once both extensions are installed, go back to the “Explorer” tab by clicking on the file icon on the left sidebar.
Navigate to the “Day01_CourseOverview” folder and create a new file called “test.py” by hovering over the CMSE802 folder and clicking the “New File” icon.
Open the “test.py” file and type the following code:
print("Hello CMSE802")
Save the file.
Run the Python file by clicking the triangle icon on the top right corner of the editor.
The output of the code will be displayed in the terminal of your operating system.
To open the terminal again, click the triangle icon on the status bar (bottom left corner) and select the “Terminal” tab.
Your terminal#
✅DO THIS: By running the Python file, you will see the output in the terminal of your operating system, i.e., a text-based interface used to control your computer. We will be using the terminal for various tasks throughout the class.
To open the terminal:
Click on the triangle icon on the status bar (bottom left corner) of VS Code.
Select the “Terminal” tab from the dropdown menu.
To close the terminal:
Click on the “X” icon on the right side of the terminal window.
Refresher on Jupyter#
What is Jupyter?#
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
From: https://jupyter.org/
Jupyter works best as a communication tool. Notebooks will be used throughout this class as a way for instructors to communicate with students and for students to communicate with instructors. We will use Jupyter notebooks extensively for pre-class assignments, in-class assignments, homework and Exams.
Jupyter notebook tutorial#
✅DO THIS: Watch running Jupyter notebook in VS Code video (~6 min).
Don’t worry about setting up the virtual environment, we will do that in a couple of days.! For the moment choose the default python
✅DO THIS:
In VS Code, navigate to your
Day01_CourseOverview
folder,Create a new file in the folder and call it
test.ipynb
.Open the new file and type:
print("Hello CMSE802")
Click the triangle on the left-hand side of the cell to run the cell,
If you don’t have Jupyter, you will be prompted to install:
Follow the prompt to
install kernels from the marketplace
,Install
Jupyter notebook
extensions,
Go back to the notebook file
Click on the triangle again to run,
Choose the Python interpreter to run,
If a popup appears suggesting new install, go ahead,
Go back to the notebook file and and click on the triangle again to run,
If a popup appears suggesting installing
ipykernel
, go ahead,
Run the code cell again.
Type of cells in the notebook#
Markdown cell#
In the tutorial before, you are running Python code in code cells. There is another type of cells called markdown cell (such as this one).
Markdown cells consist of formated text, images and equations much like your favorite word processor.
✅DO THIS: Create a new markdown cell below with the following steps:
Click the blank area on the left side of this cell (so this cell is indicated with a blue bar but you cannot edit it).
Press
B
to create a new cell below.The new cell should be indicated with a blue bar.
Press
M
to indicate that this is a markdown cell.Tell us about your day in the markdown cell.
Press
SHIFT-ENTER
together to “run” the cell.
Run code cells#
The following are two code cells written in the Python programming language. This simple code is a tool to make it easy to search your jupyter notebooks which can be handy if you are looking for something from a previous class. The example searches for an exact string in your notebook files in the current directory and displays links to the files as output.
✅DO THIS: Run code cells below
To run the code, first select the code cell with your mouse and then hold down the SHIFT key while hitting the ENTER key. You will have to hit the enter key twice to run both cells.
#Search string
search_string = "containers"
#Search current directory
directory ='.'
print("You just run the 1st cell.")
import os
import os.path
from IPython.core.display import display, HTML
search_string = search_string.lower()
links=[]
for fn in os.listdir(directory):
if 'ipynb' in fn:
if os.path.isfile(fn):
found = False
with open(fn,'r') as fp:
for line in fp:
line = line.lower()
if search_string in line:
links.append("<a href="+fn+" target=\"_blank\" >"+fn+\
"</a></br>")
break
if links:
display(HTML(' '.join(links)))
else:
print('string ('+search_string+') not found.')
print("You just run the second cell.")
Jupyter notebook and this class#
Much of this course will be taught in a “flipped” style. This means we give you notebooks to review outside of class and we use in-class time to work on meaningful problems. Many of our pre-class assignments notebooks use videos to help communicate ideas (in lieu of lecture time in class).
There are lots of resources on the web for using Jupyter notebooks and programming with the Python programming language. The following are some recommended websites for getting more information. If these sites do not work consider using your favorite search engine.
Getting an account on GitHub#
In this course, we will be using GitHub for version control and collaboration. If you don’t have a GitHub account, please follow the steps below to create one:
Open your web browser and go to the GitHub website (github).
Click on the “Sign up” button located at the top right corner of the page.
Fill in the required information in the sign-up form, including your username, email address, and password.
Make sure to use your .edu email address, as GitHub offers some free features for students.
Complete the verification process by following the instructions sent to your email address.
Once your account is verified, you can start using GitHub to collaborate on projects, contribute to open-source projects, and showcase your work.
Note: GitHub offers additional features and benefits for users with a paid subscription. However, as a student, you can take advantage of the GitHub Education program, which provides free access to certain features and tools. Make sure to explore the GitHub Education program to learn more about the benefits available to you as a student.
Assignment wrap-up#
Please fill out the form that appears when you run the code below. If running the cell doesn’t work in VS Code copy the link src
and paste in the browser. Make sure to sign in with your MSU email.
from IPython.display import HTML
HTML(
"""
<iframe
src="https://forms.office.com/r/rTmWq0JeP1"
width="800px"
height="600px"
frameborder="0"
marginheight="0"
marginwidth="0">
Loading...
</iframe>
"""
)
Congratulations, you’re done!#
© 2024 Michigan State University. This material was created for the Department of Computational Mathematics, Science and Engineering (CMSE) at Michigan State University.