Practice and reinforce the concepts from Lesson 2
Time needed: 30-40 minutes
C1_Intro_to_Python & C2_Jupyter_Notebook.ipynb
:bulb: Remember to run each code cell by pressing
Shift + Enter
or clicking the play button!
Question One: Working with Text Cells :emoji:️
Time estimate: 10 minutes
Step-by-step Instructions:
- Create a text cell and add a heading:
- Click the
+ Text
button- Type
# Basic
to create a heading 1- Press
Shift + Enter
to render the cell- Create another text cell for a subheading:
- Click
+ Text
again- Type
## Question 1
to create a heading 2- Press
Shift + Enter
to render- Create a text cell with formatted content:
- Add a new text cell
- Copy the text from the image below
- Add a hyperlink to the word "here" using this format:
[here](https://www.telebort.com/)
tip Markdown Quick Reference:
# Text
= Heading 1## Text
= Heading 2[link text](URL)
= Hyperlink**text**
= Bold textTime estimate: 10 minutes
Create a text cell for the section heading:
## Question 2
Shift + Enter
Create your first code cell:
+ Code
button#print Welcome to Telebort
print("Welcome to Telebort")
Welcome to Telebort
Create a second code cell to print multiple lines:
#print name and age
print("My name is Yong Sheng\nI am 15 years old")
My name is Yong Sheng
I am 15 years old
:bulb: Remember: The
\n
creates a new line in your output!
Advanced: Interactive Programming :computer:
Time estimate: 10-15 minutes
Step-by-step Instructions:
Create a section heading:
- Add a text cell
- Type
# Advanced
- Press
Shift + Enter
Create an interactive program that asks for user input:
- Add a code cell
- Type this code to collect user information:
python
name = input("What is your name?") age = input("What is your age?") school = input("What is your school?")
- Run the cell and answer each prompt
- Example interaction:
outputWhat is your name?Yong Sheng # user types their answer What is your age?15 # user types their answer What is your school?Telebort # user types their answer
Display the collected information:
- Create a new code cell
- Type this code to show the results:
python
print("What is your name?" + name) print("What is your age?" + age) print("What is your school?" + school) print("Hi, " + name + ". You are " + age + " years old from " + school)
- Run the cell to see your personalized output:
outputWhat is your name?Yong Sheng What is your age?15 What is your school?Telebort Hi, Yong Sheng. You are 15 years old from Telebort
tip Pro tip: Make sure to run the input cell first before running the print cell, or you'll get an error!
"NameError: name 'variable' is not defined"
Text not formatting in text cells
Shift + Enter
to render markdownInput() not working
Enter
:warning: Warning Before submitting:
- Run all cells in order from top to bottom
- Check that all outputs are showing correctly
- Save your notebook (File -> Save)
:information_source: Info
Ready to submit?
:link: Submit your exercise here
Your submission helps us track your learning progress!