Assignment 2.2 Python for Everybody | Coursera Community
Question

Assignment 2.2 Python for Everybody

  • 25 January 2021
  • 2 replies
  • 1114 views

Badge +1

2.2 Write a program that uses input to prompt a user for their name and then welcomes them. Note that input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output.

Desired output: Hello Sarah

Original sample code:

# The code below almost works

name = input("Enter your name")

print("Howdy")

Code I wrote: 

name = input('Enter your name:')
print ('Hello Sarah')

I got the desired output which is: Hello Sarah Error message was that I actually had to prompt for the user's name. How do I do this?

Other advice I got:

The name Sarah cannot appear anywhere in your program. That is called hard coding a value. You only enter Sarah after you click the <Check code> button and the dialog box opens prompting you to enter a name.

There are two steps in this assignment:

  1. prompt the user to enter a name using the input() function
  2. print the string that matches the greeting in the Desired output and the variable from step 1 (which stores the user input).

The syntax for printing two objects in Python is:

print(object1, object2)

 

How to do all this? I need help!


2 replies

H@Ramandeep Singh

Sorry to hear that you are having difficulty solving it. The advice you have received is very helpful.

According to Coursera's Honor Code, giving or receiving assignment solutions in the discussion forums is not allowed. So, we cannot post an explicit answer.

But I can give a hint: you should not put the name Sarah in your print () line. Instead, your print() line should get it from name. You have used name= in your input (), but it's not used in your print().

If you're still unsure, please review the related course material and try again.

 

Badge

[Removed by moderator, please do not share assignment answers]

Reply