你好, Again
要解决的问题
In 名为 hello.py in 的文件夹中名为 sentimental-hello, 实现一个 program that prompts a user 的ir名字, 然后打印 hello, so-and-so, where so-and-so is their provided名字, exactly as you did in 问题集 1. Except that your program this时间 should be written in Python!
提示
- 回忆一下 you can get a
str从用户那里获取get_string, 该函数声明在 thecs50library. - 记住你可以打印一个
strwithprint. - 回忆一下 you can create formatted strings in Python by prepending
fto a string itself. 例如,f"{name}"will substitute (“interpolate”) the value of the variablenamewhere you’ve written{name}.
演示
如何测试
While check50 is avai实验le for this problem, you’re encouraged to first 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 inDavidand press enter. 你的程序应该 outputhello, David. - Run your program as
python hello.py, and wait for a prompt for input. Type inInnoand press enter. 你的程序应该 outputhello, Inno. - Run your program as
python hello.py, and wait for a prompt for input. Type inKamrynand press enter. 你的程序应该 outputhello, Kamryn.
正确性
check50 cs50/problems/2026/x/sentimental/hello
代码风格
style50 hello.py
如何提交
在终端中执行以下命令提交你的作业,并按提示完成操作。
submit50 cs50/problems/2026/x/sentimental/hello