Julia_forloopguide.ipynb.txt - "cells"cell_type"markdown"metadata"source A quick guide to for loops\n\n"Computers are very good at doing dumb things

# Julia_forloopguide.ipynb.txt -...

• Essay
• 5

This preview shows page 1 - 2 out of 5 pages.

{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# A quick guide to for loops\n", "\n", "Computers are very good at doing dumb things very quickly. We use this all the time to make computers do all sorts of things for us.\n", "\n", "One of the fundamental things that happens behind the scenes in most places is something called a for loop. A for loop says \"here's a bunch of values for some variable n\". For every value, repeat these steps that I tell you to.\n", "\n", "Here's a toy example:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n" ] } ], "source": [ "for i in 1:10 # For the numbers 1 to 10 (stored in the variable i as it runs)\n", " println(i) # Print i and move to a new line\n", "end" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, we just printed i over and over again. However, think back to the capital sigma notation from the lecture. It's just doing the same thing, repeating a basic step (add this value) over and over again. We can use a for loop to do this as well:" ] }, { "cell_type": "code",

Subscribe to view the full document.

• Spring '12
• Boman
• Interior, loop, Rochester, New York

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes