Section Review of Data

Lesson Details:
July 10, 2020


I: Introduction

1. Programming Languages are the fundamental tools that are used to create computer programs. They are created to allow computers to understand the instructions the programmer is providing the computer.



2. There are many different types of programming languages in use today, but most are based on one of two common programming models: functional programming or imperative programming.



II: Body

A: SECTION REVIEW OF DATA



1. Data is the most important aspect of any program. While data is stored in a computer, it is not stored in a way that directly relates to the language being used to program the computer.



2. The easiest way to represent data stored in a computer is with binary numbers. Binary numbers can be any number between 0 and 1. This means that for any number (including positive and negative whole numbers), all you need to do is express it as a series of 1’s and 0’s. For example, the binary representation of the number 12 is 1010, which translates into 10*10+0*10+1*10 = 100 + 0 + 1 = 101 (or twelve).



3. Another way to represent data is through Hexadecimal numbers. Hexadecimal numbers are numbers represented by 16 symbols (or characters). The sixteen symbols are 0-9, A-F. These sixteen characters are actually based on the decimal system (0-9), so they can be used to represent any number between 0 and 9999. Because of this fact, hexadecimal representations of data are almost always used in binary coding languages.



4. Encoding refers to converting data into some other form that the computer can read. For example, when converting English text into binary, or when encoding binary into Hexadecimal, the data must be converted for the computer to read it.



5. The biggest mistake beginning programmers make when coding is not providing enough information to the computer to tell it what to do when a certain part of the program is executed. The easiest way to tell a computer what to do when a certain part of a program is executed is through a Boolean statement. A Boolean statement consists of a condition that is either true or false. When a condition is true or false, the result is referred to as a truth-value. When a truth-value is true, it tells the computer to perform one action when it runs a certain part of the code; when a truth-value is false, it tells the computer to perform another action when it runs a certain part of the code.



6. Another way to tell a computer what to do when a certain part of a program is executed is through an If statement. An if statement consists of a condition that determines whether or not a certain action should be performed. If the condition is true, then that action will be performed; if the condition is false, then that action will not be performed. For example, an if statement could have the following format: if ((my_condition)==true){perform_action();} . In this example, my_condition would be some Boolean expression that would determine whether or not perform_action() executes when the if statement sees it during execution; if my_condition is true while running this if statement, then perform_action() will execute; if my_condition is false while running this if statement, then perform_action() will not execute. Also, there can be multiple actions after an if statement (and thus multiple statements); these actions will only execute if their conditions are true while running their respective if statements.



7. Loops are used to repeat statements until a certain condition has been met (or until some other specific criteria has been met). The simplest loop is referred to as a “for loop” (also called a “for each” loop). A for loop repeats a set of statements based on some condition that must be true for the loop to continue repeating its actions: for(int i=0;i<10;i++){// Statements } . In this example, statements will only execute while i<10 , and statements will execute 10 times before executing again while i<11 . After statements have executed 10 times, execution will continue at the line after the for loop (or at some other later point in the program).



8. Another type of loop is referred to as a “while” loop. A while loop repeats statements until some condition becomes false: while(my_condition){ // Statements } . In this example, statements will only execute while my_condition remains true; if my_condition becomes false at any time during execution (even before statements execute), then statements will not execute and execution will continue at some later point in the program (or at some other point).



9. Another type of loop is referred to as a “do-while” loop. A do-while loop repeats statements until some condition becomes false: do{ // Statements } while(my_condition); . In this example, statements will only execute once while my_condition remains true; if my_condition becomes false at any time during execution (even before statements execute), then statements will still execute and execution will continue at some later point in the program (or at some other point). Also, there can be multiple statements and/or statements after the do-while loop (as shown above).



III: Conclusion

loader
Course content