{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "User Input\n", "===\n", "\n", "Your programs get much more interesting once you start working with user input. Instead of always running the same way, your programs run differently depending on what input your users provide." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello, who are you? Eric\n", "Hello, Eric, it's so nice to have you in class!\n" ] } ], "source": [ "# Example.\n", "\n", "name = input(\"Hello, who are you? \")\n", "\n", "print(f\"Hello, {name}, it's so nice to have you in class!\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can get as much information as you want from the user:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hi, what's your first name? Eric\n", "Hi, what's your last name? Matthes\n", "Hello, Eric Matthes!\n" ] } ], "source": [ "# Getting two pieces of input.\n", "first_name = input(\"Hi, what's your first name? \")\n", "last_name = input(\"Hi, what's your last name? \")\n", "\n", "print(f\"Hello, {first_name} {last_name}!\")" ] } ], "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 }