code: TU02 points: 10
Input something
An old favourite exercise is to greet a person! But the computer does not know your name, right? Time to meet our first variable. A variable is something that can easily be changed. You may have seen them in Scratch too, where they are often used for Lives, scores etc.
MyName = input('Please enter your name: ')
Let's break this command down:
MyName is the variable
input says that it would like you to enter something
Inside the string is what I would like to display
Now let's add a command:
print('Hello',MyName)
This not only says hello but also adds the name you entered.
MyName = input('Please enter your name: ')
Let's break this command down:
MyName is the variable
input says that it would like you to enter something
Inside the string is what I would like to display
Now let's add a command:
print('Hello',MyName)
This not only says hello but also adds the name you entered.
Exercise 1: Create your own greeting.