# That Blue Square Thing

## AQA Computer Science GCSE

May 2019: this area of the site is being built just now. I’m making progress but there are areas where there is no content yet. That will get added over the next 6 months or so.

### Programming Concepts - Input Statements

Input statements allow users to enter data to be used in a program.

This is a really fundamental area of coding. Without the ability to enter values programs aren't very flexible. It's crucial that you understand input statements and how they work.

One key idea is that you want to "capture" the values being entered. This means that you need to assign them to a variable. As a result the input part of the code needs to come after an equals sign:

print() # print a blank line
print("Name: " + yourName) # one way of printing on one line
print("Age", yourAge) # another way of printing on one line

The key thing to remember is to always assign an input value to a variable.

### Inputting numbers

Inputting numbers is slightly more complex.

Python always assumes that anything inputted using an input statement will be a string - i.e. a word (see more about data types). This includes what you might think of as a number. Python sees "42" and things it's a word made up of the character '4' and the character '2'. It absolutely doesn't think of it as a number.

This means you can't do things like this:

# this code won't work!

yourAge = yourAge + 10 # add 10 years to yourAge
print(yourAge)

To solve this problem we have to tell Python that we want to consider the input as a number. We can do this by converting the input to a number - often to an integer (a whole number).

Here's how to do that:

# this code will work!
yourAge = int(yourAge) # convert to an integer

yourAge = yourAge + 10 # add 10 years to yourAge
print(yourAge)

Sometimes you want to use a decimal number rather than an integer. Now you have to convert to a floating point number (a float data type).

print(yourShoeSize)

Note that this time I converted at the same time as the input happened. This is fine to do with integers as well - but take care to include the right number of closing brackets (I reliably miss one off and end up with a syntax error on the next line down).

### Printing Numbers

It's all very well converting inputs to numbers, but you need to be a little careful when you print them out again.

Python can cope with a simple print statement with a number in it, like this:

print(yourAge)

But if you want to print the number out on the same line as words you need to be careful how you do it. Take a look at the code below to see.