Section Overview
In this project you are going to learn about how computers make decisions based on a Boolean process, how flowcharts can be used to plan tasks. Your end task will be to produce a quiz on scratch.
Section ObjectivesDuring this section you are going to learn the basics of programming conditionals. This section will cover using if, then else statements in Scratch or Small Basic. Which you choose to use for your quiz project is up to you.
|
Section TerminologyVariables
Commenting Code User Friendly |
Using Scratch to create a quiz - optional section
If you choose to use scratch to complete your project then please watch this video:
Click here - Youtube: using Scratch to create a quiz
Click here - Youtube: using Scratch to create a quiz
Using Small Basic to create a Quiz
Small Basic is a text based programming language which is very user friendly, it gives you prompts as you start to type and helps ensure your spelling is correct.
You do not need to use indentations in our code however using indentations is recommended to make your code neat and easy to read.
Small Basic Video 1
During this introduction to small basic video you will learn the following:
You do not need to use indentations in our code however using indentations is recommended to make your code neat and easy to read.
Small Basic Video 1
During this introduction to small basic video you will learn the following:
- How to use the text window
- How to comment your code
- How to store an input from the user
Small Basic Video 2
During this second Small basic video you will learn
During this second Small basic video you will learn
- How to use if, then, elseif, else
- code indentation
Small Basic Video 3
During this second Small basic video you will learn
During this second Small basic video you will learn
- How to use variables to to track and add your score
Further help
Small Basic Step by step instructions
Step 1
Step 2
To great a new window where your program will run type the following on the first line:
TextWindow.Title = "Welcome to Small Basic"
This will create a text window and give the text window a title. You can put any title you like within the speech marks, this is just to make it user friendly.
Step 3
Step 4
Next you will be asking the user for their name . To help keep your coding neat and to have a reference point to remind yourself or what each section of code does we can make comments within the code. comments are for your benefit only and will not be read by the computer what it runs your program. to make a comment use the ' sign followed by your comment.
This line of comment should change to green if you have done it correct.
Step 5
Underneath this comment starting on line 4 you can now ask the user what is their name:
TextWindow.Write ( "What is your name? ")
This line of code tells the computer to please the content in the text window and it tell the computer to write the given string in the text window. (When using the command Write it will not drop down a line where as the command WriteLine inserts a new line after it has written the text)
Note: After the ? there is a space, this is to ensure a space is put between the ? and the users input of their name.
Step 6
We are now going to create a variable to store the users name and we will call the variable - name - , remember we can call the variable anything we like but it is a good idea to keep sensible variable names to help you to see what each variable is doing. think of it as a storage box and if you have lots of storage boxes storing things then it is a good idea to clearly label the boxes relevant to their content.
name = TextWindow.Read ()
This is creating a variable called 'name' and telling the computer to store the content of whatever the user types in in the variable (box) labeled 'name' .
Run your program to check you have no problems so far.
Step 7
We are now going to recall whatever the user typed in and us it in a sentence to reply to the user.
TextWindow.WriteLine ( "Hello " + name)
This time we use 'WriteLine' , this will drop down to a new line after the text is written.
The program will write the string "Hello" and then recall the content of whatever is stored in the variable 'name' and write that after the word "hello". Notice there is a space left within the speech marks after the word "Hello ", this is to ensure there is a space between hello and the name.
Step 1
- Open Small Basic
- Click on New
Step 2
To great a new window where your program will run type the following on the first line:
TextWindow.Title = "Welcome to Small Basic"
This will create a text window and give the text window a title. You can put any title you like within the speech marks, this is just to make it user friendly.
Step 3
- Save your work by clicking Save As - choose a sensible place to save
- Run your program to check it works so far by clicking "Run"or press F5 - Your should have a text window appear.
Step 4
Next you will be asking the user for their name . To help keep your coding neat and to have a reference point to remind yourself or what each section of code does we can make comments within the code. comments are for your benefit only and will not be read by the computer what it runs your program. to make a comment use the ' sign followed by your comment.
- On line 3 type
This line of comment should change to green if you have done it correct.
Step 5
Underneath this comment starting on line 4 you can now ask the user what is their name:
TextWindow.Write ( "What is your name? ")
This line of code tells the computer to please the content in the text window and it tell the computer to write the given string in the text window. (When using the command Write it will not drop down a line where as the command WriteLine inserts a new line after it has written the text)
Note: After the ? there is a space, this is to ensure a space is put between the ? and the users input of their name.
Step 6
We are now going to create a variable to store the users name and we will call the variable - name - , remember we can call the variable anything we like but it is a good idea to keep sensible variable names to help you to see what each variable is doing. think of it as a storage box and if you have lots of storage boxes storing things then it is a good idea to clearly label the boxes relevant to their content.
name = TextWindow.Read ()
This is creating a variable called 'name' and telling the computer to store the content of whatever the user types in in the variable (box) labeled 'name' .
Run your program to check you have no problems so far.
Step 7
We are now going to recall whatever the user typed in and us it in a sentence to reply to the user.
TextWindow.WriteLine ( "Hello " + name)
This time we use 'WriteLine' , this will drop down to a new line after the text is written.
The program will write the string "Hello" and then recall the content of whatever is stored in the variable 'name' and write that after the word "hello". Notice there is a space left within the speech marks after the word "Hello ", this is to ensure there is a space between hello and the name.
You should now have the basic skills to have a short chat with the user, continue this by asking the user more questions and recalling the variables within your response.
Going for Gold
During this third Small Basic Video you will learn how to use text within the graphics window.
During this forth Small Basic video you will learn how to use buttons within the graphics window.