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

Accepting this Assignment

  1. Accept this assignment via GitHub Classroom.
  2. After about a minute, refresh the page and ensure you see “You’re ready to go!”.

Getting Started

Log into code.cs50.io, click on your terminal window, and execute cd by itself. You should find that your terminal window’s prompt resembles the below:

$

Next execute

get50 sentimental-hello

in order to download a directory called sentimental-hello into your codespace.

Then execute

cd sentimental-hello

in order to change into that directory. Your prompt should now resemble the below:

sentimental-hello/ $

Execute ls by itself, and you should see a few files and folders:

hello.py

If you run into any trouble, follow these same steps again and see if you can determine where you went wrong!

Specification

Write, in a file called hello.py, 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 in David and press enter. Your program should output hello, David.
  • Run your program as python hello.py, and wait for a prompt for input. Type in Bernie and press enter. Your program should output hello, Bernie.
  • Run your program as python hello.py, and wait for a prompt for input. Type in Carter and press enter. Your program should output hello, Carter.

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/fall/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

In your terminal window, execute the below.

submit50 sentimental-hello

You may submit as many times as you would like up until the deadline. To confirm your submission, go to https://github.com/classroom50/sentimental-hello-USERNAME, where USERNAME is your GitHub username. You should see the code from your latest submission.