Coding challenge

Write some code that will generate a random number $r$, between 0 and $2\pi$, then compute $sin(r)+k$, where $k$ is some constant that you can choose (10, 5, -5.323, etc.). Something like
k=3
r=2.0*math.pi*math.random()
y=k+sin(r)
should do it. Generate 1,000 of these y's and find the average of them. Can you explain your result? What about $k+\sin(2r)$? $k+\sin(100r)$?

Type your code here:


Lua reference

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code: