Up until now, the output of the assignments you have created has been a bit boring. That’s because all the scripts we’ve made until this point have been static, they could only supply the same output every time they were run (unless you changed the source code). We are now going to make them a bit more interesting, by making them dynamic. We can do that by asking the user for input, and making our output dependent on this input. This is what makes most software so powerful too: processing given user input to produce a specific output.
For this task, you will create just that: a small first script that uses input to produce a specific output. Write a simple script called `hello.py`, which should ask the user to input their name and then print the exact string `“Hello {name}!”` to the screen.
-!- CODE language-bash -!-$ python3 hello.py
Please write your name: CodeGrade
Hello CodeGrade!
CodeGrade is your virtual teaching assistant for your coding classroom. You teach, CodeGrade takes care of the rest.
With our 40+ built-in fully automatically graded Introduction to Python assignments for university-level courses, you can start teaching Python at your institution with confidence now. Or, scale your classroom with CodeGrade's tools.
Book a personal 30-minute demo now and we'll show you how to get started with CodeGrade in less than 1 hour!