Difference between revisions of "Making AI with Python"
(→Introduction) |
|||
Line 23: | Line 23: | ||
Nothing happens, no matter what you say. Let's fix that: | Nothing happens, no matter what you say. Let's fix that: | ||
+ | user_says = input('Hi or Bye?') | ||
if user_says == 'Hi': | if user_says == 'Hi': | ||
print('Hello!') | print('Hello!') | ||
elif user_says == 'Bye': | elif user_says == 'Bye': | ||
print('Bye... :(') | print('Bye... :(') |
Revision as of 14:48, 15 September 2023
Introduction
This manual will only work if you know Python. If you don't, go learn it at: Getting Started With Python Programming.
Let's start off with a little challange:
Say 'hi' to the user when they greet the code, and 'bye' when the user says bye to the code.
First, we need to now what the user says. So we can send them a little input box called 'user_says':
user_says = input('Hi or Bye?')
Great! Now we need to recognise if they are saying 'Hi', or if they are saying 'Bye'.
user_says = input('Hi or Bye?') if user_says == 'Hi': pass elif user_says == 'Bye': pass
Nothing happens, no matter what you say. Let's fix that:
user_says = input('Hi or Bye?') if user_says == 'Hi': print('Hello!') elif user_says == 'Bye': print('Bye... :(')