{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# String input\n\nThis demo shows how to get input from the user.\nFor more sophisticated inputs based on input boxes etc.\nplease see the methods in the module ``itom.ui``.\n\nInputs in this demo will force an input line in the command line\n(green background). Put some text there and press return to continue.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "name = input(\"Please put your name after the colon:\")\nage = input(\"Please put your age:\")\n\ntry:\n age_ = int(age)\n print(\"Hello %s. Your age is %i\" % (name, age_))\nexcept Exception:\n print(\"Your age could not be interpreted as integer\")" ] } ], "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.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }