Hello
Implement a program that prints out a simple greeting to the user, per the below.
$ python hello.py
What is your name?
David
hello, David
Specification
Instructions for Harvard College students
- Head to GitHub and, after signing in, accept this assignment on GitHub Classroom.
- After about a minute, refresh the page and click the link to visit your personal GitHub Classroom assignment page.
- On the assignment page, click the green Code button and choose Open with Codespaces.
- Cilck New codespace and then, if prompted, Create codespace.
- Once your Codespace loads, click the
+
button in the bottom section of your window (next to the word “bash”). You should then see blue text appear that says/workspaces/sentimental-hello-USERNAME
(whereUSERNAME
is your GitHub username).
Instructions for non-Harvard College students
Create a new directory called hello
inside of your pset6
directory by executing
~/ $ mkdir ~/pset6/hello
Create a new file called hello.py
inside your hello
directory.
In hello.py
, write 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.
Usage
Your program should behave per the example below.
$ python hello.py
What is your name?
Emma
hello, Emma
Testing
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 inBrian
and press enter. Your program should outputhello, Brian
.
Execute the below to evaluate the correctness of your code using check50
. But be sure to compile and test it yourself as well!
check50 cs50/problems/2021/summer/sentimental/hello
Execute the below to evaluate the style of your code using style50
.
style50 hello.py
This problem will be graded only along the axes of correctness and style.
How to Submit
Instructions for Harvard College students
Harvard College students (those with an @college.harvard.edu email address) should submit this problem via GitHub, not via Gradescope.
In your Codespace, execute the below, replacing USERNAME
with your actual GitHub username.
submit50 classroom50/sentimental-hello USERNAME
Instructions for non-Harvard College students
- Download your
hello.py
file by control-clicking or right-clicking on the file in CS50 IDE’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 the correct filename, or the autograder will fail to run on it, and it will score no correctness points! - Click “Upload”.
You should see a message that says “Problem Set 6: Sentimental (Hello) submitted successfully!” You won’t see a score just yet, but if you see the message then we’ve received your submission!