0% found this document useful (0 votes)
38 views3 pages

1 Lab 01 - Assignment

This document provides instructions for a lab assignment on using Jupyter Notebook and Python. Students are asked to write code to convert between Celsius and Fahrenheit, including getting user input for temperature. They are also instructed to add comments to their code to identify themselves and describe what the code is doing. The document demonstrates debugging code by having students fix a name error in sample code. Students are asked to complete tasks that involve writing conversion code, rewriting the code to use input, and debugging another code example.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

1 Lab 01 - Assignment

This document provides instructions for a lab assignment on using Jupyter Notebook and Python. Students are asked to write code to convert between Celsius and Fahrenheit, including getting user input for temperature. They are also instructed to add comments to their code to identify themselves and describe what the code is doing. The document demonstrates debugging code by having students fix a name error in sample code. Students are asked to complete tasks that involve writing conversion code, rewriting the code to use input, and debugging another code example.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

lab01_assignment

January 14, 2021

1 Lab 01 - Assignment
Hello Everyone! Welcome to your first lab :)
Goal: Today we are going to learn about using Jupyter Hub and Jupyter Notebook and how we
can use them to write line of codes in Python.
Let’s get started!
Let’s begin by writing a simple code to convert Celcius to Farenheit.
To do so we need to know the formula for this. Let’s search Google and type in “Convert celcius
to farenheit”.
Hint: The website that we are looking for is http://www.mathisfun.com/measure/thermometer.html.

1.1 TASK 1
Now that we have the formula we need to create two variables to store our data.
• Create a variable celcius and assignt temperature of 20.5 to it
[4]: # Your solution here

• Now we need another variable farenhiet to store the temperature in farenheit, but this time
instead of a value we need to assign an expression (using the conversion formula)

[5]: #Your solution here

• Let’s use print function to show our result


[6]: #Your solution here

• Change the celcius temperature to 55 and print the result in farenheit


[7]: #Your solution here

Helper functions - Python functions can help us with tasks


We can change our program so that instead of manually entering temperature for celcius, we can
ask user to input it.
To do so we need a function called input in Python to help us.

1
• Let’s try this! Uncomment (remove the # symbol) the code and run it

[ ]: #celcius = float(input("Temperature in Celcius: "))

1.2 TASK 2
• Rewrite your code using the input function above:
[3]: #Your task solution goes here

Comments - Documenting your work


Commenting is a good way to explain each line of your code so others who reads it can understand
what you are trying to do.
Also I want all of you to add a comment like the example below at the begining of your code to verify
your code, as well as saving each notebook by adding you name after the Assignment_1_YourName.

[ ]: #Created on Thursday, January 18, 2021


#@author: Ghazal Reshad (student ID)
#Lab 01 - Jupyter Notebook

Debugging - Finding and Fixing Errors


Another important part of programming is to know how to debug your code when there is a problem
or error. Today we are going to learn how to do this in Jupyter.
• Let’s try to run the (uncomment it first) code below:

[ ]: #Name = 'Rachel'
#print('Hi there', name)
#subtotal = 19.99
#tax = 1.13 * 19.99
#total = subtotal + tax
#print('your total is:', total)

The error you got is called “NameError” written in bold red on top. And also the debugger is
pointing to the line where the problem lies. you can use this information to fix the problem. This
is also called a ‘syntax error’. # Note here, Python is case sensitive. - What does it mean? It
means that the way you type th name of your variables matters. For example:
myVar = 9 #this spells with a upper case letter V
myvar = 0 #this spells with a lower case letter v
This spelling difference makes them two different variables!

1.3 TASK 3
• Now given this information, copy the code here, edit it to fix the error and try to run it again.
[2]: # You TASK solution goes here

2
1.3.1 How to submit your assignment
1. Deadline: 1 week from your lab session
2. To submit follow instructions on the how-to-submit tutorial file.

You might also like