Homework 1

sample homework

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

using PlutoTeachingTools, PlutoUI
3.8 s

Sample Homework

This notebook showcases some of the features of PlutoTeachingTools.jl and how to use these to write homework assignment in Pluto.

md"""
# Sample Homework

This notebook showcases some of the features of [`PlutoTeachingTools.jl`](https://github.com/JuliaPluto/PlutoTeachingTools.jl) and how to use these to write homework assignment in Pluto.
"""
452 μs

Tip

For a deeper tour of PlutoTeachingTools.jl, check their documentation

tip(md"""For a deeper tour of `PlutoTeachingTools.jl`, check their [documentation](https://juliapluto.github.io/PlutoTeachingTools.jl/example.html)""")
115 ms

Useful functionalities

PlutoTeachingTools.jl has some functions like correct, still_missing, here a few demoes

md"""
## Useful functionalities

`PlutoTeachingTools.jl` has some functions like `correct`, `still_missing`, here a few demoes
"""
377 μs

Got it!

Yay ❤

correct()
99.5 ms

Missing Response

Replace missing with your answer.

still_missing()
23.9 ms

Keep working on it!

The answer is not quite right.

keep_working()
22.1 ms

Keep working on it!

you can also give custom text to the boxes

keep_working(md"you can also give custom text to the boxes")
30.2 ms

Hint

this is a hint, hover the box to unblur the text

hint(md"this is a hint, hover the box to unblur the text")
18.5 ms

Exercise 1: a simple exercise

Replace missing with the value 1.

md"""
## Exercise 1: a simple exercise

Replace missing with the value `1`.
"""
340 μs
x
missing
x = missing
12.9 μs

Missing Response

Replace missing with your answer.

if ismissing(x)
still_missing()
elseif x == 1 && x isa Int
correct()
elseif x == 1 && !(x isa Int)
b1 = almost(md"""Your variable has the right value, but it's not quite the right answer. Read carefully the instructions""")
b2 = hint(md"""What type should the value of x be?""")
md"""
$b1
$b2
"""
else
keep_working(md"""That is not the right answer! Keep trying!""")
end
35.5 ms

here is a short demo of how it looks like when the student tries to solve the exercise

md"""
here is a short demo of how it looks like when the student tries to solve the exercise
"""
227 μs
Resource("https://user-images.githubusercontent.com/49938764/249749643-8cc12de3-2b50-4182-b95d-686c2c18332c.mov", :width => 500, :autoplay => "", :loop => "")
6.5 ms

Exercise 2

Write a function called myfun that takes as input an integer and returns its square.

Define a variable called y and assign myfun(3) to it.

md"""
## Exercise 2

Write a function called `myfun` that takes as input an integer and returns its square.

Define a variable called `y` and assign `myfun(3)` to it.
"""
416 μs

Oopsie!

Make sure that you define a function called myfun

let
if !@isdefined(myfun)
func_not_defined(:myfun)
else
test_values = [1, 2, 3, 4, 5]
msg1 = correct()
for t in test_values
if myfun(t) != t^2
msg1 = keep_working(md"Test failed for input $t, expected $(t^2), but got $(myfun(t))")
break
end
end
end
end
119 ms

Oopsie!

Make sure that you define a variable called y

if !@isdefined(y)
var_not_defined(:y)
elseif y == 9
correct()
else
keep_working(md"Evaluated expression y = $y is incorrect.")
end
34.2 ms

and here is a quick demo of the exercise in action

md"""
and here is a quick demo of the exercise in action
"""
328 μs
Resource("https://user-images.githubusercontent.com/49938764/249748007-d0b2d773-6b21-49d4-89db-ad737af510fe.mov", :width => 500, :autoplay => "", :loop => "")
62.5 μs