# 5. Wagon Wheel¶

Studios are in-class activities to give you hands-on practice with new concepts. The first half is the Walkthrough, an instructor-led programming problem. The second half is for you to work on individually or in pairs in class.

These problems are not graded, and you are not obligated to finish them. Get as far as you can while in class, and use them as an opportunity to play with and solidify new concepts.

## Walkthrough¶

For this walkthrough, we will write a program that uses functions to draw a line star with a chosen number of lines.

## Studio¶

Draw this pretty pattern.

Hint: Think about the repeating element that makes up this image. It probably looks a lot like what you’d draw on the sidewalk if you wanted to play foursquare.

## Bonus Missions¶

1. Modify the square function given to you in section 5.4 of the textbook. Modify this function so that instead of computing the square, it can compute any positive integer exponent that is given to the function.

0, 1, 1, 2, 3, 5, 8, 13, 21...

Notice that each number in the series is simply the sum of the previous two numbers of the series. Write a function called fib(n) that takes in an integer n which is greater than 2 and returns the nth Fibonacci number. For example fib(4) would return 3, fib(6) would return 8 etc. (Hint: Remember that zero-based indexing we talked about...)

Note that it is tricky to compute fib(0) = 0 and fib(1) = 1 with the concepts we have currently covered. If you have done the prep work for chapter 6, however, you should be able to update your function to cover those two values.

Finally, investigate the following question: what is the largest value of n that returns the correct Fibonacci number? Why does this function stop working after that point?
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://coding101.devetry.com/Studios/wagon-wheel", "fetch_time": 1547807695000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2019-04/segments/1547583660020.5/warc/CC-MAIN-20190118090507-20190118112507-00208.warc.gz", "warc_record_offset": 50308010, "warc_record_length": 5369, "token_count": 412, "char_count": 1779, "score": 3.71875, "int_score": 4, "crawl": "CC-MAIN-2019-04", "snapshot_type": "latest", "language": "en", "language_score": 0.9357270002365112, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00026-of-00064.parquet"}