Transcript Arrays
1.
Know what a variable is, and why they are fundamental in programming.
2.
Know the different uses of variables 3.
Understand how you can add data and read data from a variable.
The best way to think of a variable is an empty box The box is able to store something, but if you want to add something new, then item that’s in there will be lost.
All variables will have a name given to them by the programmer.
Put stuff in here
In programming there are 4 main types of variables.
String
“Some text”
Integer
37
Boolean
True or False
Double
3.45
How to declare a variable Declaring Initialising Variables must follow these rules in Python Must begin with a letter (a z, A - B) or underscore (_) Other characters can be letters, numbers or _ Case Sensitive Can be any (reasonable) length There are some reserved words which you cannot use as a variable name because Python uses them for other things
Computers were invented to complete really difficult maths This means that they are great for doing maths Type Adding Mathematical notation Python Notation 2 + 2 2 + 2 Subtracting 9 - 4 Multiplication 2 x 9 Division 8 ÷ 2 9 - 4 2 * 9 8 / 2
A program that doesn’t allow input of data, is useless You need to be able to take information in, process it and then output the information
Allow a user to enter a number of miles. Display the same distance in kilometres.
Allow a user to enter a number of kilometres. Display the same distance in miles.
Also convert into Furlongs!
Conversions Miles to Kilometer – 1 miles to 1.6 Kilometers Miles to Furlongs – You need to find this out