I'm a Python Programmer

I'm a Python Programmer — page 3
LOOPS AND VARIABLES If you've done some coding before you will know that one of the most important programming concepts is the loop If you want your code to do something over and over again it's much quicker to use a loop instead of copying out the code several times Let's look at how this works in Python STEP 1 START A NEW FILE STEP 2 GET CODING IDLE Run IDLE See step 4 from page 4 if you need help Click the File menu then choose New File File Edit New File Carefully type in this code Press enter after each line Untitled Open STEP 3 SAVE YOUR CODE STEP 4 RUN YOUR CODE Python3 5 Shell Click File Save IDLE File Edit Type loops as the filename Open Save Click Save Click the mat Run Optio Run menu Python then choose Run Module Run Module STEP 5 USE A LOOP The for command starts the loop a is a variable see page 7 The number of times to repeat the loop Steps 1 to 4 are a simple way to make our program say hello three times But what if you wanted to make it say hello ten or a hundred times There is a quicker way Delete your code and change it to the code shown to the right Check your code carefully for mistakes Save and Run your code What happens The commands you want to repeat must be indented Python should automatically indent lines for you If it doesn't just use the space bar or the tab key to indent the code exactly as shown A colon must be at the end of the line