Conversation program, help

This is the place for queries that don't fit in any of the other categories.

Conversation program, help

Postby el_manu » Tue Aug 20, 2013 12:33 pm

Write a program that can have this conversation with you:

Hello, what is your name?

> John
Nice to meet you John
My name is Eliza
How do you feel now John?
> sad
I feel sad sometimes too.
Why do you feel sad?
> there are only three weeks left in the Challenge
I know how you feel John



The program should print the questions and use input to get the answers (shown above in black). It should use the answers later in its responses (so if you type Nicky instead of John in the first step, it would use Nicky in all the later responses.

The conversation should be exactly the same as the example above, except with different responses from the user substituted in. It is amazing how human sounding the conversation can be already!

In the last step (answering Why do you feel <feeling>?), if you try to ask Eliza a question (ending with ?), then instead of I know how you feel <name>, Eliza should say: Hey! I ask the questions.

With a little more work, you might be able to convince someone that a computer really can have feelings!




Don't answer until I post my code though.!!!!
Last edited by el_manu on Tue Aug 20, 2013 12:53 pm, edited 1 time in total.
el_manu
 
Posts: 87
Joined: Mon Aug 19, 2013 8:30 am

Re: Question

Postby el_manu » Tue Aug 20, 2013 12:46 pm

hi

Mekire: DO NOT DELETE YOUR POSTS AFTER RECIEVING HELP. If you feel that your actions would be regarded as unethical by your professors then you should reconsider asking for help in a public place.
Last edited by el_manu on Fri Aug 23, 2013 12:34 am, edited 1 time in total.
el_manu
 
Posts: 87
Joined: Mon Aug 19, 2013 8:30 am

Re: Conversation program, help

Postby Mekire » Tue Aug 20, 2013 12:57 pm

Basically all you need is to get input; format the input into strings to print; and do some minimal if/else statements.

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Conversation program, help

Postby el_manu » Tue Aug 20, 2013 1:12 pm

I will figure it out and post my code here for checking or help later.
el_manu
 
Posts: 87
Joined: Mon Aug 19, 2013 8:30 am

Re: Conversation program, help

Postby el_manu » Tue Aug 20, 2013 1:38 pm

Code: Select all
name = input('''Hello, what is your name?
> ''')
print('Nice to meet you {} '.format(name))
print("My name is Eliza")
feelings = input('''How do you feel now {}?
> '''.format(name))
print('I feel {} sometimes too.'.format(feelings))
question = input('''Why do you feel {}?
> '''.format(feelings))
if question.endswith('?'):
   print('Hey! I ask the questions.')
else:
  print('I know how you feel {}'.format(name))


Is this correct before I send it off.
el_manu
 
Posts: 87
Joined: Mon Aug 19, 2013 8:30 am

Re: Conversation program, help

Postby Mekire » Tue Aug 20, 2013 2:52 pm

Looks pretty good. Generally we don't use triple quote strings like that though. You can put "\n" in a string if you want a line break instead. Also watch your indentation. Your indents should all be 4 spaces (anything else is heresy plain and simple). On most IDEs you can set it up so the tab key adds 4 spaces instead of 1 tab so you don't actually need to hit the spacebar 4 times.

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 5 guests

cron