🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

AltSchool Africa Entrance Exam Notes.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

AltSchool Africa Entrance Exam Notes AltSchool Africa Entrance Exam Notes 1 Introduction to Computer Science 2 Introduction to Computer Science 2 What is a Computer?...

AltSchool Africa Entrance Exam Notes AltSchool Africa Entrance Exam Notes 1 Introduction to Computer Science 2 Introduction to Computer Science 2 What is a Computer? 2 Computer Software and Hardware 3 Computer Software Deep Dive 3 System Software and Application Software 4 Intro to Computer Programming 5 Computer Programming 5 Compilers and Interpreters 6 Bit, Byte, Variable, Data Type & Type Checking in Programming 7 Data Structures, Control Flow, Loops & Recursion 10 Big O Notation, Programming Paradigms 17 Functional Programming, Algorithms, Code Editors & Operating Sys 22 Introduction to Data 28 What Exactly is Data 28 How it All Started 29 Various Career Options with Data 30 Introduction to Data Analysis 31 Intro to Data Analysis 31 Responsibilities of a Data Analyst 33 Data Analysis Process 34 Introduction to Data Science 36 Intro to Data Science 36 What do Data Scientists do 37 Introduction to Data Engineering 38 What is Data Engineering? 38 Who are Data Engineers and What do they do? 41 What makes Data Engineering so special? 42 Introduction to Computer Science Introduction to Computer Science Hi, I'm Chidi. and I will be taking you on Introduction to Computer Science. This class is central to everything you'll be learning in this program because you simply cannot learn to code without understanding how computers work. I know you might have taken a class similar to this one at some point in your academic journey, and might be tempted to brush this aside. Please don't. It is a pretty straight forward lesson that'll prepare you for what's to come. You'll be done before you know it. So sit back, relax and get ready to learn. What is a Computer? What is a computer? Take a deep breath and ask yourself right? That's pretty funny. You think you know? Yes? no? You have known the definition of computer science since you were in primary school. Right? Exactly. But, what if I tell you that a computer is human? And the difference between you and a computer is that it listens and does whatever you command it to do. Would you believe that? Now let's get started. A computer is an electronic device or machine that takes inputs from the user, processes data according to the set of instructions, outputs of the data and temporarily or permanently stores the data internally. Just like human metabolism, a computer is a combination of interrelated parts of components. Human beings take in food to get energy, and computers, being an electronic device, require electrical energy to function effectively. A computer cannot perform any of its functions without its components, and they are: hardware and software. Computer Software and Hardware From the word “hard”, which means something that can be touched or felt or held. Right? Computer hardware can be defined as a physical component of a computer. Examples of computer hardware are keyboard, Mouse, the processor, memory devices, monitor, the printers we use in the office, and the central processing units, CPU, and others. Now let's go to the software part of things. From the word "soft", which means something that can neither be touched or held. Computer software refers to the components of a computer that performs a specific task on a computer, based on the collection of instructions or procedures. Software is a compendium of executable code that is written in high or low-level programming languages. Examples of computer software are Adobe Photoshop, Google Chrome, WhatsApp, Twitter, Slack or the Operating system we have both on your mobile phone and your laptops. You must be wondering, Why are we diving into computer software and not hardware? Well, who doesn't like a soft life? So yeah, welcome to the soft life. Now, shall we begin. Computer Software Deep Dive The main reason why we are deep diving into computer software is because that's what Altschool Africa School of Engineering is all about. People often think computer science as a profession is all about Microsoft Office, Microsoft Word, Excel or Corel draw. But I'm here to tell you that it is more than that, and as a matter of fact it's very broad. Today, with the advancement of technology, computers have become a part of our life so much that we can no longer do without it. So, it is safe to say that software engineering is from computer software engineering, and computers can be in from mobile phones, either Android, iPhone or Windows whichever one. It can also be laptops, smartwatch, even your TV if you have smart TVs. There are two branches of computer software, which are systems software and application software. Just like a computer comprises hardware and software. Computers software also consist of system and application software. Things are getting broader right? Don't be scared. But remember, computer science is so broad that we are only looking at the introduction to computer science. System Software and Application Software System software acts as an intermediary between the user and the computer. It's designed to use and maintain the computer hardware. For instance, think of a house with running water, electricity and it's well-furnished, right? So system software is like the running water, electricity and furniture in the house, and without these things, it will be very difficult to live in the house. This means without systems software in a computer, applications software cannot be executed or run successfully. However, system software is a concept of system programming, which involves the programming of software that accesses and controls the inner workings of a computer hardware. System programming is another field and in fact, an entirely different under computer science. Examples of system software include operating systems like Mac OS by Apple, Windows by Microsoft, and linux. Other examples are firmwares, device drivers and utility softwares. Application software is designed to help users perform a specific task on a computer. Again, for instance, think of a house with running water and electricity, also well-furnished, but without home appliances such as the TVs, the home theater, washing machine, so many things, right? An application software is the home appliances. It brings livelihood and effectiveness to the house. Imagine your laptop or phone without a browser, without WhatsApp, without Slack, Twitter, so many things. That would be pretty boring to use. You get a point now right? Application programming is a concept of application software. And in fact, it involves building and developing the application, that is the mobile, the desktop and the web, that runs on the computers. And that's what altAfrica's school of engineering is all about. And your journey to become an applications software engineer begins now. Examples of application software are Microsoft Office, the vlc media player you use, your WhatsApp, Slack, Google Chrome, Firefox, Twitter and so many other apps. A computer is nothing but an empty device without its components. And each of its components are interconnected to one another, such that they all depend on one another. Do you now believe that your computer is just like a human being but in the form of an electronic device? You still don't believe it? Okay, go ahead and uninstall the browser. The operating system and all the software. What do you have left? Empty and functional less device. You've come a long way, now let's take a glass of water, and digest all we've learnt in this lecture. And that's our lesson on introduction to computer science. It's quite straightforward, isn't it? Don't forget that you can always consult the lecture slides when you need a refresher on what we discussed. N.B. I should add here that learning about computer science, helps to develop problem solving, critical thinking and complex analytics skills which are quite useful, especially when working with complex algorithms and big data. Don't worry, you will learn about these concepts later Thank you for learning, and all the best. Intro to Computer Programming Computer Programming Hello, welcome to this course Introduction to Programming Languages and Concept and Tools of the Trade. My name is Ornella, and I'll be taking you through this first section of the course, while Jerry will continue where I stop. Now, what is computer programming? Imagine, it's 10am in the morning, and you've just woken up and you would like to make a cup of coffee. How would you go about it? You stand up, you walk to the kitchen, you boil water, add coffee and milk if you like. Your coffee is ready. That's how programming works. But now, you're writing these instructions for a computer to perform with contingencies like, what if we run out of water? Computer programming, also known as coding, involves well structured instructions for a computer to execute. That means detailed instructions for a mindless machine. Now let's talk about computer languages. Unlike the steps to make your coffee, which are detailed in English, a computer only understands machine languages, which are zeros and ones. Computer programs are written in a programming language, but it doesn't mean a computer can directly interpret that language. Programming languages are divided into two: low-level languages and high-level languages. Low-level languages can also be divided into machine languages and assembly languages. Machine languages can be directly understood by a computer, while assembly language needs to be translated by an assembler into machine language. Assembly language is less complicated than machine language, and it has some human-readable parts. While high-level languages use compilers and interpreters. Compilers and Interpreters Now let's talk about compilers and interpreters. Compilers and interpreters convert computer programs written in one language into another, which is usually a machine language which can be processed by a computer. However, while a compiler translates the entire program at once, an interpreter translates just one statement of the program at a time. A compiler is generally faster than an interpreter because it analyzes each statement just once, while an interpreter must analyze each time, for example, in a loop. What is data and information? Data is a collection of values. These values can be symbols, numbers, letters, etc. Data can be analog or digital. Digital data are programmed in step by step sequence and jump from one value to the next. They are discrete and discontinuous. Analog data are continuous and fluctuate infinitely within a range. For example, sound. Analog devices include loudspeakers, thermometers and amplifiers. Data can be converted from digital to analog and vice versa using ADC and DAC converters. For example, when measuring the sound picked up by a microphone. Information refers to processed data. When data is interpreted, it provides context with which we can make informed decisions. For example, collecting rainfall and temperature data over a period of time can help scientists predict weather conditions in a location. And this is it for me, I'll be handing you over to Jerry who'll continue this course? Bit, Byte, Variable, Data Type & Type Checking in Programming Hi guys, my name is Jerry and I'm a Program Manager with the Team at AltSchool Africa and I'm super excited that you chose to go on this journey with us. In the earlier videos, Ornella already took you through the earlier part of this course and I'm here so that we can go a bit further. And we're going to be talking about some concepts in computing and programming in general. The first concept that we're going to explain is bits and bytes. You might ask, “what is a bit?” You probably have heard it somewhere. A bit is denoted with a small letter b, while a byte is denoted with a capital letter B. Bytes, you know, you've actually used this term a lot of times, but you might not know exactly what it means when we say gigabytes, kilobytes, Megabytes. Bytes are commonly used when referring to size of data on a computer, while bits measurements can be seen more often in describing network speed. Therefore, when network speed is 200 MBPS, which is 200 MBPS per second, this means that it will take about 8 seconds to download a file of 200 megabytes. Get it? Since 1 byte is 8 bits, it is going to take you 8 seconds to download a file of 200 megabytes. Moving on to variables. Variables are used to store data that is likely to be reused and/or manipulated in a program. They provide a way of labeling data so our programs can be understood more clearly by the reader and ourselves. You can think of a variable as a data container, which you can call when you need the data that is in it. It is important to use descriptive words when naming a variable as it can actually get difficult to manage obscure variable names in large programs. Very, very important. Let's move on to assigning a value to a variable. In most programming languages, the equal sign/the assignment operator, which is the equal sign, is used to assign a value to a variable, with the variable name on the left side of the operator and the value on the right side. For example, in Python you can see; Python: name = ‘Ade Tiger’ Some languages have special keywords that come before declaring a variable, like JavaScript. In JavaScript, this time you can see Javascript: const name = ‘Ade Tiger’ Whenever we need to access the name in our application, we can easily use the variable name and manipulate it based on the data type of the value assigned to our variable. That brings us to data types. I mean, I just used that term and I just brought it up here without exactly explaining what it is. In computer programming, a data type refers to the attributes of a value which provides the compiler on what type of mathematical, logical or relational operations can be carried out on it without throwing an error. That sounds like a very complex statement. A data type just tells the computer or the compiler what kind of data you're giving to it. If you supply the computer with a number, for example, or a text, you need to tell the computer that, okay, this is actually a text that I'm giving or this is actually a number that I'm giving you. Imagine we have two values, the value "4" and the value "Ade Tiger". We can easily find the square of 4. But that same operation cannot be carried out on the other value which is Ade Tiger. You cannot find the square of the phrase 'Ade Tiger'. So, you need to tell the computer that, okay, this is text, this is a number. So, that it can know that, okay, these are the operations that I can carry out on this particular data value, and these are the other things that I cannot also carry out on that same piece of data. Some operations that can be applied to values of one data type obviously do not make sense when applied to values of another data type. When we try the wrong operations on data types, an error is thrown, either on the compilation or execution of our program. There are different kinds of data types and most programming languages support the following data types. The first one you can see on your screen is the integer data type. It represents non-decimal numbers, including negative ones. Then you have the Floating point numbers. This includes numbers with decimals. Let's take it back a bit, integers represent any number. It can be number one, it can be number five, it can be number 20. Then floating point numbers this time, you can have 5.6, you can have 6.3. This still now takes me to the next data type which is the Boolean operator. Boolean operators are used to represent conditionals. They are used to, sort of, depict when something is either false or true. We'll see that as we proceed, but just understand that when you have a Boolean operator, it can either be false or true, one or zero; I'm tempted to say yin or yang, but let's move on to the next data type. The next data type is text, very important: text/string. Text/string represents words containing characters which may be made up of letters, digits, symbols, and signs. Understand what I said there, texts/strings can have letters, digits, symbols, and signs. So that means that a number can also be recognized by the computer as a string depending on how you want to use the data, you're going to still get more familiar with this as we proceed. The next data type that we are looking at is the Null data type. This represents an unknown or an unspecified value. And the next data type is Pointers. Pointers help us store the memory address of a value. This brings us to Type Checking in programming languages. Type checking is a process that involves ensuring that operations carried out on values of each particular data type in a computer program are valid. A type error is thrown, if an invalid operation is carried out. For example, when we talk about carrying out a square operation on a text like Ade Tiger, you can't do that. It's going to throw a type error. Another example, the code: “x = 4 * ‘Ade Tiger’”, will throw an error because the multiplication operator can only be used with numbers. So you cannot multiply a number with a text. It's just wrong. So it's going to throw an error. There are two major methods of type checking. The first one is the static and the second one is the dynamic. Static type checking is done at compile time - and compile time is when a compiler translates the source code. Type checking is done and an error is immediately thrown and the code doesn't run. This is useful because type errors can be caught early in the development cycles. Seen in languages like C++, Java, C, Go, TypeScript and more. Dynamically type programming languages do type checking at runtime, which is when the program is running. At this point, the program runs but throws an error when the mismatch type code block is executed. This is seen in languages like JavaScript, Python, Ruby, and this can make it quite difficult to catch type errors in development, especially if the program is not properly tested. Data Structures, Control Flow, Loops & Recursion Let's move on to another big concept in computing, which is data structures. So oftentimes you deal with large amounts of data that are related in some way, and we'll need an efficient way to organize and structure them. For example, if you're working with a dataset of students in a class, or employees in an organization. A data structure provides you with a way of organizing the data to use them effectively and efficiently. Think of it as a collection of data that are related. Examples of data structures include arrays, stacks, queues, linked lists, heaps, trees, and more. You're going to be seeing them as we proceed. Let's look at what arrays are. An array is a collection of data, each of which can be identified with an index or key. Array indexing depends on the programming language. There are different ways to index the arrays. While some are zero-based - with the first element of the array being at index zero and the next, index one. This can be seen in languages like C, JavaScript, Python, and Java. The others are one-based. So languages like Fortran, MatLab, Pascal, are one-based. The first element is at index one. Some are n-based. The base index can be freely chosen. These are for languages like Perl, PHP and some others. Still speaking on arrays, you can easily calculate the position of each element by simply adding an offset to a base value. In dynamically-typed languages such as JavaScript, an array can contain different data types, while in languages like C or C++, an array can only contain similar data types. Let's take this back a bit. Remember, we said that you need data structures when you're dealing with large data sets. In languages like JavaScript, you can use an array to collect more than one data type. So, you can have a number, you can have a string. Or in languages like C or C++, your array can have only similar data types in it. Let's look at stacks. Stacks are a linear data collection that only allows addition and removal of items in a First in Last out order (FILO). Get that it's very important. They allow addition and removal of items in a first in last out order. A very simple example of a stack is a tin of pringles or a stack of plates. The last item to be added to the stack is the first item to be removed. A stack can be applied in different scenarios, such as calling the stack that stores function calls, or undo and redo operations. Another similar data structure to stacks is the queue data structure. But instead of the first in last out structure, the queue uses the First in, First out order (FIFO). Just like a queue in a public place. You have a line of people, maybe trying to use an ATM, and you notice that the first person to get there is the first person to come out. Makes sense, right? Queues can be applied to the following operations such as - Job Scheduling for operations which may take a long time, and it can also be used - to handle congestion in network requests. Another data type we should look at is the linked list. A linked list is a linear data structure that includes a series of connected nodes. A node contains the data and the memory address to the next node. The first node in the linked list is called the head, while the last node points to the null. As you can see in the illustration it's pointed out for you. The first node in a linked list is called the head while the last node points to the null. Let's look at Hash tables A hash table is an efficient way to store, modify and retrieve data, especially when a large amount of data is involved. A hash table stores elements in a key-value pair, where the key is an integer unique to the hash table for indexing the values, and the value is the data associated with the key. The integer value is generated by a hash function, so in a way it is like an array that links a key to a specific data value. A hash function takes the key and generates an integer of fixed size which will then be associated with that key - so this is used in concepts like cryptography, security and the rest of them. You can think of a hash table as a form of a dictionary. The name is the key and the entry is a value. A hash table can be useful when trying to keep a database of users in an organization. This is something that you are going to be seeing a lot as you proceed. Alright, we've talked about a couple of data structures. Let's talk about the concept of a control flow. The control flow of a program is the order in which that program executes. There are different types of control flows. The first one is the sequential control flow, which is the default flow of any program. In the sequential control flow, the code execution is happening in a sequence at which the program was written. The next kind of control flow is the selection or the conditional. In this scenario, a statement or a set of statements is executed when a particular condition is true, and ignored when the condition is false. I previously mentioned conditional. In this particular kind of control flow, something has to be either true or false for something to happen. So you get to determine it. You can decide to say "Okay, If this number is 5 and above, then let this happen". Or you can decide to also say "if it is less than 5, then let this other action happen". The third kind of control flow is the repetition, and in this scenario a sequence is repeated multiple times until a particular condition is met. Remember I mentioned you can decide to do a particular action if the results of one action is 5 or higher. In this particular scenario, you can decide to keep on doing a particular action until one condition is met. For example, your condition can be, let a variable be equal to 10. And the condition is until that variable gets to a particular number - you can say maybe 15 - keep on adding one to the number. That means the action will keep on carrying out until 10 goes from 10 to 11 to 15. Then that means that that condition is met. It might be a bit confusing now, but trust me, you are going to get more used to these kinds of concepts, and you're going to need to use them a lot as well. So this is also known as Decision control. It means that a program will do one of multiple alternatives based on if a condition resolves to true or false, just as I explained with 10 to 15. For example, when making coffee, you can decide to add milk if you like it, or else you can decide to leave it. Or you can even decide to add more milk if the amount of milk you added at the first time is not enough for you. So the condition there is "I want milk, I want a particular amount of milk and I'm going to keep on adding milk till I am good". I hope this makes sense. Some conditions statements you can find in different programming languages include: the if, the if else, the nested if and the switch. For the ‘if’, it's just as the term 'if' indicates. If a particular condition is met or if a particular action is carried out, then this other action should be carried out (If - continues as normal after the block). For the 'if else', as it also indicates, if something happens, do this. Else, do this other thing (If/else - alternatives follow the else block and then continue as normal). Then there is the ‘nested if’. The nested if is a bit more complex. For the nested if conditional statements, it's used for more complex scenarios and you'd have an if statement inside another if statement, Eg. if (water) {if (boilingWater){}}. You're going to see that materialise as we continue to push on. You also have the ‘switch statement’. A switch conditional statement is used for even more complex scenarios, and it's very similar to the if else statement. It is present in programming languages like JavaScript, Java, C, C++, C# and more. Switch statements use keywords like switch, case, break and the rest of them. A typical switch statement looks just like you can see on your screen. You can see the switch expressions which embodies the whole statement. And then you can see the keywords, case value, the block. The block contains the condition and it also contains the value and the data that you're working with. You also have the break keyword which indicates a stop in the sequence. This brings us to Loops. Interesting that I said loop in the last statement. Loops are very important in the grand scheme of things. You're going to be using loops a lot. Remember our code for making coffee from earlier. Now, imagine we wanted to make cups of coffee for all 90 students in a particular class. How do we go about it? We could rewrite our code 90 times but that wouldn't be efficient. Imagine having to write a code that makes coffee for 90 students, and having to write it 90 times. That's where loops come in. We can use something like a loop, which is a programming feature that lets us repeat a sequence of instructions until a condition is met - which is the break condition. In the example earlier, the condition we're using in this scenario is the number of students in the class, which is 90. If a break condition is not specified, the loop will continue running for as long as your program is active, which is called an infinite loop. And we don't want infinite loops. Unless there's any scenario where you need to use that, you definitely want to avoid infinite loops. There are different kinds of loops. Most programming languages have at least two types of loops, and both are identified by the key words: the For loops and the While loops. While both of these loops can be used interchangeably, For loops are more commonly used when we know the actual number of times we want the loops to run - just like our coffee example, we know the loop has to run 90 times. And the structure for a for loop is usually in the format: "You can see for, and then you can see "initialize," the condition, the increment and what's to do afterwards. For (initialize; condition; increment/decrement) { doStuff() } That tells you that for the number of times that a condition is met, you can carry out the increments or the decrement, and then you can also carry out the action that you wish to carry out. A FOR loop consists of a header portion and a body portion, with the header typically consisting of three parts and the body containing the code to be executed while our condition remains true. In the first part of the header, we initialize our loop variable. This is then checked against a condition we declare in the second part. If our condition is met, the code in the body of our loop runs. Our loop variable is then increased or decreased by a particular value, which we declare in the third part of the loop header, checked against the loop condition, and if it is met, the loop runs again. Now this brings us to the second type of loop, which is the While loop. A while loop runs for as long as a conditional statement passed into it remains true. It is usually used when you do not know how many times your loop will run. For example, instead of making coffee for 90 people, imagine we're making coffee till we run out of boiled water and we do not know how much water it would take to make a cup of coffee. Also, we do not know how much water will be wasted in between the processes. A while loop will be useful in this case. As you can see the structure: "while (boiled water); this is specifically for our example, While we have boiled water, make coffee. While (boiledWater) { makeCoffee() Usually, there will be a way to update the boiled water variable in our make coffee function so that whenever we make coffee, the boiled water variable is updated. It becomes falsy when we run out of boiled water and the while loop will stop running. I hope that makes sense. Now this brings us to another really important concept in the grand scheme of things, which is recursion. Imagine reading through a Wikipedia entry about a historical event, and then you come across another interesting event. You click on that and then you find even another interesting event, and you just keep on clicking until you no longer find anything that interests you, and then you stop. That sort of tells you what recursion is. A recursion is a program that calls itself until it gets to a base condition. A recursive function can call itself directly or indirectly. A direct recursive function calls itself within itself, while an indirect recursive function calls other functions that eventually calls the original function. This might sound a bit complex, but trust me, it gets easier as we proceed. It is important to have a base condition else your function continues to call itself infinitely. Usually, a recursion problem can be solved with loops and vice versa. Let's try to create a recursive function that adds integers from one to a given number in JavaScript. So we have our function sumrange, which returns a range plus sumrange in bracket range minus one. The code above will infinitely or throw an error as there is no base case. Practical Recursion function sumRange(range) { return range = sumRange(range - 1) } So let's add a base case. So this time we have our function but we've indicated our base case this time and this works but only for positive numbers only. The same error thrown in the first code will be seen here if zero or a negative number is shown. function sumRange(range) { if (range === 1) { return 1 } return range = sumRange(range - 1) } Let's fix that. You can see this time with a base case and type checking. We now have a working recursive function to find the sum of numbers up to a range. function sumRange(range) { If (range

Use Quizgecko on...
Browser
Browser