{ "metadata": { "kernelspec": { "name": "python", "display_name": "Python (Pyodide)", "language": "python" }, "language_info": { "codemirror_mode": { "name": "python", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8" } }, "nbformat_minor": 5, "nbformat": 4, "cells": [ { "id": "80c19b23-b438-47c9-a982-1b0ab88dae87", "cell_type": "markdown", "source": "
In this activity, you must:
\n\n\"David Bowie is the author of Starman\"\n \n# Create a list of zoo animals\nanimals = [\"Lion\", \"Elephant\", \"Giraffe\", \"Zebra\", \"Penguin\"]\n\n# Adds a new item to the end of the list\nanimals.append(\"Tiger\") \n\n# Outputs the 4th item\nprint(animals[3]) \n\n# Outputs the full list\nprint(animals) \n\n# Outputs the 2nd to the 3rd item\nprint(animals[1:3]) \n\n# Removes the 4th item of the list\nanimals.pop(3) \n\n# Outputs a list item in a sentence\nprint(animals[1] + \" is one of the animals in the zoo\")\n\n\n\n
In the code below, your teacher will model how to use a for loop with a range
\nThey will demonstrate how the loop counter variable is a number that increases by 1 with each iteration
\nThey will then demonstrate how this can be used in order to output each item of a list on a separate line
\n\nIn the code below there is a list of 6 personalities
\nYou must complete the code so:
\n\nThe output for each person should look something like this\n
Alice is always very cheerful\n
\n# Loop through a list of animals and output each as an f string\nanimals = [\"lion\", \"tiger\", \"bear\", \"zebra\", \"elephant\"]\n\nfor i in range(0,5):\n print(f\"There is a {animals[i]} at our zoo\")\n\n\nUse what you have just learned to output the Name, marks and grade for each student in the class
\nThe output for each student should be something like this
\nAlex : 28 Marks : Grade 4\n\n\n