100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Data C8 Lab 1: Expressions | Spring 2025, Complete Solutions

Rating
-
Sold
-
Pages
19
Grade
A
Uploaded on
17-04-2025
Written in
2024/2025

Data C8 Lab 1: Expressions | Spring 2025, Complete Solutions











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
April 17, 2025
Number of pages
19
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Content preview

Lab 1: Expressions
Welcome to Data Science 8: Foundations of Data Science! Each week you will complete a lab assignment like
this one. You can't learn technical subjects without hands-on practice, so labs are an important part of the
course.

Before we get started, there are some administrative details.

Labs are required. There are two ways to receive credit for each lab.

1. (The normal way) Come to your lab section and work on the lab as directed. Before you leave, you need to
submit the lab and have a staff member check you off to confirm that you came to lab section and
attempted to make progress while you were there. You do not need to finish the lab or answer every
question correctly to receive full credit. However, you do need to try; that's why we check you off. Expect to
discuss your progress briefly with a staff member before they will check you off. The lab must be submitted
by Friday night, even if it is incomplete, to get credit for attending.

1. (The hard way) Lab assignments will be posted Sunday night. If you complete the entire lab so that all tests
pass and submit it by 9:59 AM on Wednesday, then you don't need to physically attend lab for the rest of
the week.

Collaborating on labs is more than okay -- it's encouraged! You should rarely be stuck for more than a few
minutes on questions in labs, so ask a neighbor or an instructor for help. (Explaining things is beneficial, too --
the best way to solidify your knowledge of a subject is to explain it.) Please don't just share answers, though.

You can read more about course policies (http://data8.org/sp18/policies.html) on the course website
(http://data8.org/sp18).


Today's lab

In today's lab, you'll learn how to:

1. navigate Jupyter notebooks (like this one);
2. write and evaluate some basic expressions in Python, the computer language of the course;
3. call functions to use code other people have written; and
4. break down Python code into smaller parts to understand it.

This lab covers parts of Chapter 3 (http://www.inferentialthinking.com/chapters/03/programming-in-
python.html) of the online textbook. You should read the book, but not right now. Instead, let's get started!

,1. Jupyter notebooks
This webpage is called a Jupyter notebook. A notebook is a place to write programs and view their results.


1.1. Text cells
In a notebook, each rectangle containing text or code is called a cell.

Text cells (like this one) can be edited by double-clicking on them. They're written in a simple format called
Markdown (http://daringfireball.net/projects/markdown/syntax) to add formatting and section headings. You
don't need to learn Markdown, but you might want to.

After you edit a text cell, click the "run cell" button at the top that looks like ►| to confirm any changes. (Try not
to delete the instructions of the lab.)



Question 1.1.1. This paragraph is in its own text cell. Try editing it so that this sentence is the last sentence in
the paragraph, and then click the "run cell" ►| button . This sentence, for example, should be deleted. So
should this one.




1.2. Code cells
Other cells contain code in the Python 3 language. Running a code cell will execute all of the code it contains.

To run the code in a code cell, first click on that cell to activate it. It'll be highlighted with a little green or blue
rectangle. Next, either press ►| or hold down the shift key and press return or enter .

Try running this cell:


In [1]: print("Hello, World!")

Hello, World!



And this one:


In [2]: print("\N{WAVING HAND SIGN}, \N{EARTH GLOBE ASIA-AUSTRALIA}!")

, !


The fundamental building block of Python code is an expression. Cells can contain multiple lines with multiple
expressions. When you run a cell, the lines of code are executed in the order in which they appear. Every
print expression prints a line. Run the next cell and notice the order of the output.

, In [3]: print("First this line is printed,")
print("and then this one.")

First this line is printed,
and then this one.


Question 1.2.1. Change the cell above so that it prints out:

First this line,
then the whole ,
and then this one.


Hint: If you're stuck on the Earth symbol for more than a few minutes, try talking to a neighbor or a TA. That's a
good idea for any lab problem.




1.3. Writing Jupyter notebooks
You can use Jupyter notebooks for your own projects or documents. When you make your own notebook, you'll
need to create your own cells for text and code.

To add a cell, click the + button in the menu bar. It'll start out as a text cell. You can change it to a code cell by
clicking inside it so it's highlighted, clicking the drop-down box next to the restart (⟳) button in the menu bar,
and choosing "Code".

Question 1.3.1. Add a code cell below this one. Write code in it that prints out:

A whole new cell! ♪ ♪


(That musical note symbol is like the Earth symbol. Its long-form name is \N{EIGHTH NOTE} .)

Run your cell to verify that it works.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Jumuja Liberty University
View profile
Follow You need to be logged in order to follow users or courses
Sold
546
Member since
4 year
Number of followers
415
Documents
2647
Last sold
1 hour ago

3.9

115 reviews

5
60
4
15
3
20
2
4
1
16

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions