Computing- Programming with small basic
Transcript of Computing- Programming with small basic
Computing- Programming with small basic Year 8 /Spring term 1
Key Word Definition Example
Program A set of instructions that a computer
can understand An Application on a phone
Programming
language
A specially written code used for
writing applications Scratch, Small Basic, Python
Intellisense The inbuilt list that helps complete
Small basic commands
Commands Special words that are instructions for
the computer to do something Writeline ()
Output Display text on a screen TextWindow.Writeline (“Hello World”)
Input Read in a value- normally stored in a
variable Name =TextWindow.Read ()
Variable Assigning a value to a location in
memory- given a meaningful name UserName, Age, Answer
Statement
A single line of code with commands-
Could be either for a property or an
operation
TextWindow.Writeline (“Hello World”)
Property A statement that changes the way the
window looks TextWindow.Title “My First Program”
Operation A statement that carries out an action Area = length *width
Condition
to test a variable against a value and
act in one way if the condition is met by
the variable or another way if not.
If weekday = "Y" Or weekday = "y" Then TextWindow.WriteLine("Sorry it's a school day, time to get up")
EndIf
For Loop A loop FOR when we know how many
times to repeat Drawing a regular shape
While loop A loop that continues WHILE a
condition has or has not been met
Reading through a list that
might be different lengths
every time
GoTo A branching statement that sends you
to a different section of code
Return to the beginning of a
menu or make a program run
again
In your own Year 8 Computing Folder, create a new folder and call it 2. Programming with Small Basic This is where you will save your worksheets and programs during the unit Small basic is a programming language that bridges between visual coding like Scratch and text based languages like Python. Small Basic provides you with an extremely simple yet powerful development environment with features like instant context-sensitive help.
OUTPUT To output a line of text on the screen we use the TextWindow.Write(“Text to show”) or TextWindow.Writeline(“Text to show”) INPUT To read in data to a variable and store it for use in the program Name =TextWindow.Read ()
STATEMENTS, PROPERTIES AND OPERATIONS When you give an instruction to the computer, you create a statement. You can write a program by creating just one statement or by creating two or more statements in a particular sequence. Your statements can include either Properties or Operations
We add comments to code, so that we can understand our code, or other programmers understand what we are trying to do. Small Basic uses a single apostrophe (‘) at the beginning of the line- Comments then appear in green, but do not appear in the running code
You should always start variable names with a letter.
You can use letters, digits, and underscores in the names of your variables.
You should name your variables so that they describe the values that they store.
When you name your variables, you should not include certain reserved words, such as If, For, and Then.
CONDITIONS- IF THEN/ELSE
To create code where the program chooses which option to follow we use an IF statement to check a condition: IF Condition to be checked THEN Do this Statement if true ELSE Do this statement if false ENDIF
When you write a program, you can specify as many conditions as you want by using the ElseIf keyword. You check through a set of options and the program will carry out the first one it comes to that is True
In this example, when the computer evaluates a statement as true, the computer performs the operation for that condition and then proceeds to the end. NOTE: They have to be in a LOGICAL sequence for it to work (Low – High or High – Low)
LOOPS
In general, you use a For..EndFor loop to run code a specific number of times. To manage this type of loop, you create a variable that tracks how many times the loop has to run.
BRANCHING
Sometimes, you may want the computer to break the flow and jump to another line of code while the program is running.
You can also use the Goto statement to make a program run forever.