Hello, Again
Problem to Solve
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 1. 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}
.
Demo
How to Test
While check50
is available 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 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
.
Correctness
check50 cs50/problems/2023/summer/sentimental/hello
Style
style50 hello.py
How to Submit
Per Step 4 below, after you submit, be sure to check your autograder results. If you see SUBMISSION ERROR: missing files (0.0/1.0)
, it means your file was not named exactly as prescribed (or you uploaded it to the wrong problem).
Correctness in submissions entails everything from reading the specification, writing code that is compliant with it, and submitting files with the correct name. If you see this error, you should resubmit right away, making sure your submission is fully compliant with the specification. The staff will not adjust your filenames for you after the fact!
- Download your
hello.py
file by control-clicking or right-clicking on the file in your codespace’s file browser and choosing Download. - Go to CS50’s Gradescope page.
- Click Problem Set 6: Sentimental (Hello).
- Drag and drop your
hello.py
file to the area that says Drag & Drop. Be sure it has that exact filename! If you upload a file with a different name, the autograder likely will fail when trying to run it. Ensuring you have uploaded files with the correct filename is your responsibility! - Click Upload.
You should see a message that says “Problem Set 6: Sentimental (Hello) submitted successfully!”