{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Assignments - If Statements\n", "===" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Simple If Statements\n", "---\n", "\n", "Imagine an alien was just shot down in a game. Create a variable called alien_color and assign it a value of 'green', 'yellow', or 'red'.\n", "\n", "Write an if statement to test whether the alien’s color is green. If it is, print a message that the player just earned 5 points.\n", "\n", "Write one version of this program that passes the if test and another that fails. (The version that fails will have no output.)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If-else statements\n", "---\n", "\n", "Choose a color for an alien as you did in the previous exercise and write an if-else chain.\n", "\n", "- If the alien’s color is green, print a statement that the player just earned 5 points for shooting the alien.\n", "- If the alien’s coor isn’t green, print a statement that the player just earned 10 points.\n", "- Write one version of this program that runs the if block and another that runs the else block." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If-elif-else statements\n", "---\n", "\n", "Turn your if-else chain from the previous exercise into an if-elif-else cahin.\n", "\n", "- If the alien is green, print a message that the player earned 5 points.\n", "- If the alien is yellow, print a message that the player earned 10 points.\n", "- If the alien is red, print a message that the player earned 15 points.\n", "- Write three versions of this program, making sure each message is printed for the appropriate color alien." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }