7.1 Hello (again)
What to do
In a file called hello.py
in a folder called sentimental-hello
, implement a program that prompts a user for their name, and then prints hello, so-and-so
, where so-and-so
is their provided name, exactly as you did in Problem Set 2. Except that your program this time should be written in Python!
Hints
- Recall that you can get a
str
from a user withget_string
, which is declared in thecs50
library. - Recall that you can print a
str
withprint
. - Recall that you can create formatted strings in Python by prepending
f
to a string itself. For example,f"{name}"
will substitute (βinterpolateβ) the value of the variablename
where youβve written{name}
.
How to Test
Youβre encouraged to test your code on your own for each of the following.
- Run your program as
python hello.py
, and wait for a prompt for input. Type inDavid
and press enter. Your program should outputhello, David
. - Run your program as
python hello.py
, and wait for a prompt for input. Type inInno
and press enter. Your program should outputhello, Inno
. - Run your program as
python hello.py
, and wait for a prompt for input. Type inKamryn
and press enter. Your program should outputhello, Kamryn
.
How to Submit
- Click and accept the Homework Link on the homework main page for this week.
- Complete each assignment for this week in the Github Codespaces environment.
- Save and click βCommit changesβ.
- The autograder runs automatically; see the Actions tab for feedback.