你好, 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, 该函数声明在 the cs50 library.
  • 记住你可以打印一个 str with print.
  • 回忆一下 you can create formatted strings in Python by prepending f to a string itself. 例如, f"{name}" will substitute (“interpolate”) the value of the variable name where 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 in David and press enter. 你的程序应该 output hello, David.
  • Run your program as python hello.py, and wait for a prompt for input. Type in Inno and press enter. 你的程序应该 output hello, Inno.
  • Run your program as python hello.py, and wait for a prompt for input. Type in Kamryn and press enter. 你的程序应该 output hello, Kamryn.

正确性

check50 cs50/problems/2026/x/sentimental/hello

代码风格

style50 hello.py

如何提交

在终端中执行以下命令提交你的作业,并按提示完成操作。

submit50 cs50/problems/2026/x/sentimental/hello