Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Created on Cognitive Class Labs
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
" <a href=\"https://cocl.us/topNotebooksPython101Coursera\">\n",
" <img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Ad/TopAd.png\" width=\"750\" align=\"center\">\n",
" </a>\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://cognitiveclass.ai/\">\n",
" <img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Ad/CCLog.png\" width=\"200\" align=\"center\">\n",
"</a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1>Loops in Python</h1>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<p><strong>Welcome!</strong> This notebook will teach you about the loops in the Python Programming Language. By the end of this lab, you'll know how to use the loop statements in Python, including for loop, and while loop.</p>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Table of Contents</h2>\n",
"<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
" <ul>\n",
" <li>\n",
" <a href=\"#loop\">Loops</a>\n",
" <ul>\n",
" <li><a href=\"range\">Range</a></li>\n",
" <li><a href=\"for\">What is <code>for</code> loop?</a></li>\n",
" <li><a href=\"while\">What is <code>while</code> loop?</a></li>\n",
" </ul>\n",
" </li>\n",
" <li>\n",
" <a href=\"#quiz\">Quiz on Loops</a>\n",
" </li>\n",
" </ul>\n",
" <p>\n",
" Estimated time needed: <strong>20 min</strong>\n",
" </p>\n",
"</div>\n",
"\n",
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"loop\">Loops</h2>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"range\">Range</h3>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Sometimes, you might want to repeat a given operation many times. Repeated executions like this are performed by <b>loops</b>. We will look at two types of loops, <code>for</code> loops and <code>while</code> loops.\n",
"\n",
"Before we discuss loops lets discuss the <code>range</code> object. It is helpful to think of the range object as an ordered list. For now, let's look at the simplest case. If we would like to generate a sequence that contains three elements ordered from 0 to 2 we simply use the following command:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Use the range\n",
"\n",
"range(3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Chapter%203/Images/LoopsRange.png\" width=\"300\" />"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"for\">What is <code>for</code> loop?</h3>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The <code>for</code> loop enables you to execute a code block multiple times. For example, you would use this if you would like to print out every element in a list. \n",
"Let's try to use a <code>for</code> loop to print all the years presented in the list <code>dates</code>:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This can be done as follows:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1982\n",
"1980\n",
"1973\n"
]
}
],
"source": [
"# For loop example\n",
"\n",
"dates = [1982,1980,1973]\n",
"N = len(dates)\n",
"\n",
"for i in range(N):\n",
" print(dates[i]) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The code in the indent is executed <code>N</code> times, each time the value of <code>i</code> is increased by 1 for every execution. The statement executed is to <code>print</code> out the value in the list at index <code>i</code> as shown here:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Chapter%203/Images/LoopsForRange.gif\" width=\"800\" />"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example we can print out a sequence of numbers from 0 to 7:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n"
]
}
],
"source": [
"# Example of for loop\n",
"\n",
"for i in range(0, 8):\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Python we can directly access the elements in the list as follows: "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1982\n",
"1980\n",
"1973\n"
]
}
],
"source": [
"# Exmaple of for loop, loop through list\n",
"\n",
"for year in dates: \n",
" print(year) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For each iteration, the value of the variable <code>years</code> behaves like the value of <code>dates[i]</code> in the first example:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Chapter%203/Images/LoopsForList.gif\" width=\"800\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can change the elements in a list:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Before square 0 is red\n",
"After square 0 is weight\n",
"Before square 1 is yellow\n",
"After square 1 is weight\n",
"Before square 2 is green\n",
"After square 2 is weight\n",
"Before square 3 is purple\n",
"After square 3 is weight\n",
"Before square 4 is blue\n",
"After square 4 is weight\n"
]
}
],
"source": [
"# Use for loop to change the elements in list\n",
"\n",
"squares = ['red', 'yellow', 'green', 'purple', 'blue']\n",
"\n",
"for i in range(0, 5):\n",
" print(\"Before square \", i, 'is', squares[i])\n",
" squares[i] = 'weight'\n",
" print(\"After square \", i, 'is', squares[i])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can access the index and the elements of a list as follows: "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 red\n",
"1 yellow\n",
"2 green\n",
"3 purple\n",
"4 blue\n"
]
}
],
"source": [
"# Loop through the list and iterate on both index and element value\n",
"\n",
"squares=['red', 'yellow', 'green', 'purple', 'blue']\n",
"\n",
"for i, square in enumerate(squares):\n",
" print(i, square)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"while\">What is <code>while</code> loop?</h3>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you can see, the <code>for</code> loop is used for a controlled flow of repetition. However, what if we don't know when we want to stop the loop? What if we want to keep executing a code block until a certain condition is met? The <code>while</code> loop exists as a tool for repeated execution based on a condition. The code block will keep being executed until the given logical condition returns a **False** boolean value.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let’s say we would like to iterate through list <code>dates</code> and stop at the year 1973, then print out the number of iterations. This can be done with the following block of code:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1982\n",
"1980\n",
"1973\n",
"It took 3 repetitions to get out of loop.\n"
]
}
],
"source": [
"# While Loop Example\n",
"\n",
"dates = [1982, 1980, 1973, 2000]\n",
"\n",
"i = 0\n",
"year = 0\n",
"\n",
"while(year != 1973):\n",
" year = dates[i]\n",
" i = i + 1\n",
" print(year)\n",
"\n",
"print(\"It took \", i ,\"repetitions to get out of loop.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A while loop iterates merely until the condition in the argument is not met, as shown in the following figure:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Chapter%203/Images/LoopsWhile.gif\" width=\"650\" />"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"quiz\">Quiz on Loops</h2>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write a <code>for</code> loop the prints out all the element between <b>-5</b> and <b>5</b> using the range function."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-5\n",
"-4\n",
"-3\n",
"-2\n",
"-1\n",
"0\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"for x in range(-5,6):\n",
" print(x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"<!-- \n",
"for i in range(-5, 6):\n",
" print(i)\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Print the elements of the following list:\n",
"<code>Genres=[ 'rock', 'R&B', 'Soundtrack', 'R&B', 'soul', 'pop']</code>\n",
"Make sure you follow Python conventions."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rock\n",
"R&B\n",
"Soundtrack\n",
"R&B\n",
"soul\n",
"pop\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"Genres=[ 'rock', 'R&B', 'Soundtrack', 'R&B', 'soul', 'pop']\n",
"\n",
"for genre in Genres:\n",
" print(genre)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"<!-- \n",
"Genres = ['rock', 'R&B', 'Soundtrack', 'R&B', 'soul', 'pop']\n",
"for Genre in Genres:\n",
" print(Genre)\n",
"-->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write a for loop that prints out the following list: <code>squares=['red', 'yellow', 'green', 'purple', 'blue']</code>"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"red\n",
"yellow\n",
"green\n",
"purple\n",
"blue\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"squares=['red', 'yellow', 'green', 'purple', 'blue']\n",
"for square in squares:\n",
" print(square)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"<!-- \n",
"squares=['red', 'yellow', 'green', 'purple', 'blue']\n",
"for square in squares:\n",
" print(square)\n",
" -->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write a while loop to display the values of the Rating of an album playlist stored in the list <code>PlayListRatings</code>. If the score is less than 6, exit the loop. The list <code>PlayListRatings</code> is given by: <code>PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]</code>"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n",
"9.5\n",
"10\n",
"8\n",
"7.5\n"
]
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]\n",
"rating = 0\n",
"\n",
"while(PlayListRatings[rating] >= 6):\n",
" print(PlayListRatings[rating])\n",
" rating = rating+1\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click __here__ for the solution.\n",
"<!-- \n",
"PlayListRatings = [10, 9.5, 10, 8, 7.5, 5, 10, 10]\n",
"i = 1\n",
"Rating = PlayListRatings[0]\n",
"while(Rating >= 6):\n",
" print(Rating)\n",
" Rating = PlayListRatings[i]\n",
" i = i + 1\n",
" -->"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write a while loop to copy the strings <code>'orange'</code> of the list <code>squares</code> to the list <code>new_squares</code>. Stop and exit the loop if the value on the list is not <code>'orange'</code>:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",
"orange\n",