Here are some steps to guide you:
- Use the function array to declare the array.
- Name the array spaceships
- Assign five different spaceship names as the values of the array. Come up with some cool names – this is your chance to rule the galaxy!
In the following last 3 topics of this lesson, we are going to learn how to program computers to save a collection of different types of values, We will learn about the following :
We have looked at how to store data in variables and the types of data that can be stored in variables.
The drones will need to store a collection of the sent coordinates so that agents would be able to retrieve the coordinates over a period of time.
With the knowledge from previous sections – we would store these coordinates in variables. But we want to have many of these coordinates. So we need a way of storing many variables – or a collection of variables.
To do this – we need to know how to use Arrays.
An array is a data structure that contains a collection of variables. Think of an array as a cupboard which stores containers (variables) that are related in some way. With the drones, we will use an array to store a collection of variables which contain the coordinates.
(Hover over the numbers for details)
In PHP, we create an array by giving it a name and listing all the elements we want to store in that array. Note that these elements will be stored in the order in which you list them. These do not have to be of the same data type. An array in PHP can store variables containing different types of data. The picture below shows how to create an array.
(Hover over the numbers for details)
You do not always have to create variables first before creating an array. You can create it by listing the data which was supposed to be stored in a variable.
Now it is your turn to practice. We have created an array with four names of spaceships. Let’s play around with the array by clicking on the button below. You’ll see our PHP code created around variables.
Change the names of the spaceships. Be creative and play around. Click run to see what happens.
Click on the “fork me” below to edit the PHP code directly.
Create an array with 5 spaceship names. Use the instructions below to assist you to create the array.
Here are some steps to guide you:
Click on the “fork me” below to edit the PHP code directly.
Given the array (“Galaxy x”, “Tardi”, “Serenity”); – let’s say I want to print out the 2nd item or element in the array. How would I do that?
To access elements of an array, you must use the index of the element you want. The index is a number that shows where in an array an element is stored. Note that the index of the first element of an array is 0, not 1.
(Hover over the numbers for details)
Now it is your time to practice, we have created an array with four names of spaceships. Let’s play around with the array by clicking on the button below. You’ll see our php code created around variables.
Use the index and the echo statement to print out of one of the spaceships called Galaxy X. Then try and print out the 2nd spaceship Tardi. Play around. Click run to see what happens.
Click on the “fork me” below to edit the PHP code directly.
Create an array of 5 planet names that drones might travel to in the quest of finding the lost spaceship and print out all the planets names. Use the instructions below to assist you to create the array.
Here are some steps to guide you:
4. Use the echo statements to print out all 5 planet names.
Click on the “fork me” below to edit the PHP code directly.
We learnt about arrays in this topic.
This helped us add more instructions to our drone programme.
Next up – let’s learn about associative arrays. This will help us to give our drones the ability to tell us which planets they pass, and how far away they are.
Whitespace – basically empty space (like spaces, tabs, or enter button) that makes the code look neat and organized, but the computer doesn’t care about it.
A User – is any person that interacts (by inputs) with a program without having to write the code directly. For example, you are the user to the code that makes your browser/website run. When you clicked on this pop-up, that was the input that made this explanation come up when the code detected it.
To book your spot – click here
All learners who are aspiring web developers will have an opportunity to build a website for a live NGO or charity client as part of their community service hours. This project will be run jointly with Community Hours – so all your time spent counts towards your LO credits. This event is suitable for learners, parents and their teachers.
TechWays will be providing the WordPress course and web dev resources for free to any learner wanting to participate.
Besides the amazing community service you’ll be doing for a charity in need – you’ll also be building your portfolio of web dev skills. Who knows – web dev could become a side hustle for extra income?
Book your spot HERE
Indentation – In the written form of many languages, an indentation or indent is an empty space at the beginning of a line to signal the start of a new paragraph.
Text editor – is the part of the IDE where you write the code. Most text editors highlight words with different properties like functions to help you distinguish them from one another.
Homogeneous – of the same kind; alike throughout.
Heterogeneous – diverse in character or content; containing different things
Prompt – to cause or bring about; to make something happen. For example making someone to say or write something.
Troubleshooting is a form of problem solving, often applied to repair failed products or processes on a machine or a system. It is a logical, systematic search for the source of a problem in order to solve it, and make the product or process operational again.
There are a lot of strings functions/methods in Python. Find full list in course manual. Here’s are some that you find useful in this course:
Functions
Methods
There a number of special string characters that have different functions when used inside ” “. Here’re some useful and common ones:
In programming Concatenation is a process of appending one string to another.
\ – escape character is a string character that tell Python that the next character after it should be taken as a string and not as an instruction.
str ( ) is a built-in function that converts and sequence of characters (numbers especially) in to text.
Mad Libs is a phrasal template word game created by Leonard Stern and Roger Price. It consists of one player prompting others for a list of words to substitute for blanks in a story before reading aloud.
type ( ) is a built-in function (still to cover what built-in functions are later) that determines the Data Type of any data presented.
input ( ) is a built-in function (still to cover what built-in functions are later) allows a user to insert info into a program/the code.
print ( ) is a built-in function (still to cover what built-in functions are later) that executes data inside the brackets. The results get printed out on the console/results section.
Integrated Development Environment (IDE) – A digital environment used to develop games, software, hardware, that offers integration from debugging to compiling. Essentially where you write, edit, and run to test your code.
More about variables
Info about variables
To book your spot – click here
#WOW – What Outstanding Work – Awards: join us to learn from our students.
Our top 20 learners are from St Andrews for Girls, Reddam Umhlanga, Evolve Online, Nova Pioneer and Sutherland High.
Learners will be presenting their final projects. Come celebrate their successes and lessons learnt with us at our TechWays #WOW Awards.
This event is suitable for learners, parents and their teachers. Book your spot HERE
To book your spot – click here
Calling on all high schoolers interested in tech as a career. Join us on Thursday 22 September at 5:30pm.
We will be sharing:
There are only 100 spaces – so book your spot now – please RSVP here Book
To access the recording – click here
Calling on all high schoolers interested in tech as a career to join us on 16 September at 5:30pm. If you missed it, we’ll host another one on 18 November.
We covered the following:
To access the recording – click here
To book your spot – click here
We will be talking to Noelene Kinsley from GC Network. Noelene has been specialised in the exciting career of Genetic Counseling and wants to share her passion for making the world a healthier place using genetics….and data science technology.
Let’s hear more about the trends in the health/genetics industries, where jobs are moving to and what kind of skills you’ll need in this exciting world of opportunities out there.
This event is suitable for learners, parents and their teachers. Book your spot HERE
To book your spot – click here
We will be talking to Jason Suttie from Devson. Jason has been in the tech world since he was six years old. He headed IT innovation unit at RMB and has since left to start up his own software consulting company – solving problems and building solutions for clients around the world.
Let’s hear more about the trends in the software and programming industries, where jobs are moving to and what kind of skills you’ll need in this exciting world of opportunities out there.
Book your spot HERE
Introduces Linux as an operating system, the basic open source concepts and an understanding of the Linux commands. Linux is crucial for cybersecurity.
Gives you the baseline skills you need to secure a company’s systems, software and hardware. This certificate gives practical hands-on skills to pursue a career in cyber security
Will give you skills in Information Security Threats and Attack Vectors, Attack Detection, Attack Prevention, Procedures, Methodologies and more.