Computer Science Principles
● Programming Forms.
● How programmer give instructions or steps to computer to perform
specific tasks.
● How computer process programming languages, from human
readable into computer readable programming language?
● What are the basic elements of a programming language that
computer needs to process.
● How computer handle errors, consistency and support of
multiplatforms.
Youtube/AwaisMirza
Programming Forms
Machine (or low level) Language:
Low level language, used to write steps or instructions directly to the processor to generate output. Machine
Language is very easy to understand for computer but difficult to read for humans. Programmer sends bits
(0 or 1) of information to the processor.
Assembly Language:
It uses processor register to store and manipulate data. Registers can be varied from processor to processor.
Assembler is used to convert it into machine language before computer understand the instructions.
Interpreted Language:
More human readable than assembly or machine language. Code is executed line by line by an interpreter.
Slower than assembly/machine language. Javascript is an interpreted language.
Compiled Language: Youtube/AwaisMirza
Variables
Types of Variables:
byte :
Memory space -> 8 bits, can only contain only 1 character.
byte a = 0;
Int (Integer):
Space -> 32 bits, can contain -ve and +ve values within the range.
int a = 345;
int b = a + 2;
Youtube/AwaisMirza
Variables (Continued)
Double:
Space -> 64 bits, can contain values having decimal points (-ve and +ve).
double a = 2.35;
String (an object):
Space -> unlimited, can contain sequence of characters.
String a = “abcd”;
String b = a + “efghi”;
Youtube/AwaisMirza
Functions
All the tasks that needs to be executed again and again, are added inside the blocks called functions. We
don’t need to write same code again and again, rather call that function when needed. Functions are of
different types:
No parameters and no return values:
function printError() {
window.alert(“Fields must be filled”);
}
Parameters and no return values:
function average(a, b) {
var ave = (a+b)/2;
window.alert(“Average of Numbers is: “ + ave);
} Youtube/AwaisMirza
Functions (Continued)
Parameters and return values:
function average(a, b) {
return(a+b)/2;
}
Using functions:
var result = average(25, 65);
window.alert(result);
Youtube/AwaisMirza
Scope of Variables
Variable that is defined in any particular block of code, can not be used outside that block (except its child
blocks).
function operators() {
var a = 2, b = 3, c = 4;
var d = (a * (b + c));
alert(d);
}
alert(a * (b + c)); // none of these variables can be used outside operators function.
Youtube/AwaisMirza
User Inputs
Most of the software require input from user to execute further. For example, we have calculator
application, that needs to take input from user to perform operations on data and produce result according
to that. There are different platforms from which user can give input. Like keyboard, mouse, touch
screen etc.
In different languages, there are different ways to take input from user. For example in C++, we can take
input from user like following:
int a;
cout<<”Enter a numbern”;
cin>>a;
cout<<”You have entered “<<a;
Youtube/AwaisMirza
Conditional Statements
Most of the time we need to add a condition before performing any task. Like we ask user to enter his age,
we can add a condition here that user may not enter negative value. And if user enter valid value, we can
further proceed to next operations. There are many ways to add a condition of any data, but if else
statement are most common in many languages.
Youtube/AwaisMirza
Conditional Statements (Continued
int a;
cout<<”Enter your age ”;
cin>>a;
if(a >= 0) {
// proceed further
} else {
// wrong information
}
Here >= refers to (greater or equal). We can add many other operator like <, >, <=, >=, == etc.
We can also add multiple conditions in one if statement like
if(a >= 0 && true) if(a >=0 || a == 2)
Here && refers to AND, means both conditions should be true in order to proceed. || stands for OR, means
any of condition can be true to proceed. Youtube/AwaisMirza
Repetition
In Programming, we might want to repeat things multiple times. For example, we want to print the marks
of all the students in the class. In that case we can’t write multiple print statements to print whole data.
In many programming languages, we have loops that can iterate through any kind of data.
Youtube/AwaisMirza
Repetition (Continued)
While Loop:
Int a = 0;
while(a < 5) {
cout<<a<<endl;
a = a + 1;
}
For Loop:
for(int a = 0; a<5; a++) {
cout<<a<<endl;
}
Youtube/AwaisMirza
Output:
0
1
2
3
4
Output:
0
1
2
3
4
Arrays
If we want to store multiple values in one variable, array come in handy. Array variables can only contain
values of same data type. For example if we want to store all degrees of a person, then datatype of
degree variable must be string.
Int [] numbers = [1, 2, 3, 4, 5];
In order to print all values of array, we use loops like so.
for(int i = 0; i < numbers.length; i++) {
cout<<numbers[i] + “ “;
}
output:
1 2 3 4 5
Youtube/AwaisMirza
Objects
Every thing that we see in real world is as object. People, cars, mobiles, ball etc. are all objects. To
represent real world objects in programming, developers introduced class (which represent each object).
Just like person have properties like height, weight, age etc. class also has properties that we can work
with. Just like properties, each object has some functions like person can walk, speak etc. and so for
classes.
class Person {
int age = 20, weight 70;
String hair_color = “black”;
function getAge() {
return age;
}
}
Youtube/AwaisMirza
Debugging
Almost every time when we write code, we face problems. As the code gets larger, it becomes very
difficult to find out problems. There are many ways to find (debug) the code for detecting problems.
1. IDE specific debugger
2. Manual debugging
3. Scenario Testing
4. Automated Testing
5. Test Driven Development
Youtube/AwaisMirza
What’s Next
Check out my Youtube Channel to learn actual programming with basics and
project based tutorials.
https://www.youtube.com/channel/UCIKbbV7ae7LAWa8cGnvjSPA
Youtube/AwaisMirza

Computer science principals in terms of Programming

  • 1.
    Computer Science Principles ●Programming Forms. ● How programmer give instructions or steps to computer to perform specific tasks. ● How computer process programming languages, from human readable into computer readable programming language? ● What are the basic elements of a programming language that computer needs to process. ● How computer handle errors, consistency and support of multiplatforms. Youtube/AwaisMirza
  • 2.
    Programming Forms Machine (orlow level) Language: Low level language, used to write steps or instructions directly to the processor to generate output. Machine Language is very easy to understand for computer but difficult to read for humans. Programmer sends bits (0 or 1) of information to the processor. Assembly Language: It uses processor register to store and manipulate data. Registers can be varied from processor to processor. Assembler is used to convert it into machine language before computer understand the instructions. Interpreted Language: More human readable than assembly or machine language. Code is executed line by line by an interpreter. Slower than assembly/machine language. Javascript is an interpreted language. Compiled Language: Youtube/AwaisMirza
  • 3.
    Variables Types of Variables: byte: Memory space -> 8 bits, can only contain only 1 character. byte a = 0; Int (Integer): Space -> 32 bits, can contain -ve and +ve values within the range. int a = 345; int b = a + 2; Youtube/AwaisMirza
  • 4.
    Variables (Continued) Double: Space ->64 bits, can contain values having decimal points (-ve and +ve). double a = 2.35; String (an object): Space -> unlimited, can contain sequence of characters. String a = “abcd”; String b = a + “efghi”; Youtube/AwaisMirza
  • 5.
    Functions All the tasksthat needs to be executed again and again, are added inside the blocks called functions. We don’t need to write same code again and again, rather call that function when needed. Functions are of different types: No parameters and no return values: function printError() { window.alert(“Fields must be filled”); } Parameters and no return values: function average(a, b) { var ave = (a+b)/2; window.alert(“Average of Numbers is: “ + ave); } Youtube/AwaisMirza
  • 6.
    Functions (Continued) Parameters andreturn values: function average(a, b) { return(a+b)/2; } Using functions: var result = average(25, 65); window.alert(result); Youtube/AwaisMirza
  • 7.
    Scope of Variables Variablethat is defined in any particular block of code, can not be used outside that block (except its child blocks). function operators() { var a = 2, b = 3, c = 4; var d = (a * (b + c)); alert(d); } alert(a * (b + c)); // none of these variables can be used outside operators function. Youtube/AwaisMirza
  • 8.
    User Inputs Most ofthe software require input from user to execute further. For example, we have calculator application, that needs to take input from user to perform operations on data and produce result according to that. There are different platforms from which user can give input. Like keyboard, mouse, touch screen etc. In different languages, there are different ways to take input from user. For example in C++, we can take input from user like following: int a; cout<<”Enter a numbern”; cin>>a; cout<<”You have entered “<<a; Youtube/AwaisMirza
  • 9.
    Conditional Statements Most ofthe time we need to add a condition before performing any task. Like we ask user to enter his age, we can add a condition here that user may not enter negative value. And if user enter valid value, we can further proceed to next operations. There are many ways to add a condition of any data, but if else statement are most common in many languages. Youtube/AwaisMirza
  • 10.
    Conditional Statements (Continued inta; cout<<”Enter your age ”; cin>>a; if(a >= 0) { // proceed further } else { // wrong information } Here >= refers to (greater or equal). We can add many other operator like <, >, <=, >=, == etc. We can also add multiple conditions in one if statement like if(a >= 0 && true) if(a >=0 || a == 2) Here && refers to AND, means both conditions should be true in order to proceed. || stands for OR, means any of condition can be true to proceed. Youtube/AwaisMirza
  • 11.
    Repetition In Programming, wemight want to repeat things multiple times. For example, we want to print the marks of all the students in the class. In that case we can’t write multiple print statements to print whole data. In many programming languages, we have loops that can iterate through any kind of data. Youtube/AwaisMirza
  • 12.
    Repetition (Continued) While Loop: Inta = 0; while(a < 5) { cout<<a<<endl; a = a + 1; } For Loop: for(int a = 0; a<5; a++) { cout<<a<<endl; } Youtube/AwaisMirza Output: 0 1 2 3 4 Output: 0 1 2 3 4
  • 13.
    Arrays If we wantto store multiple values in one variable, array come in handy. Array variables can only contain values of same data type. For example if we want to store all degrees of a person, then datatype of degree variable must be string. Int [] numbers = [1, 2, 3, 4, 5]; In order to print all values of array, we use loops like so. for(int i = 0; i < numbers.length; i++) { cout<<numbers[i] + “ “; } output: 1 2 3 4 5 Youtube/AwaisMirza
  • 14.
    Objects Every thing thatwe see in real world is as object. People, cars, mobiles, ball etc. are all objects. To represent real world objects in programming, developers introduced class (which represent each object). Just like person have properties like height, weight, age etc. class also has properties that we can work with. Just like properties, each object has some functions like person can walk, speak etc. and so for classes. class Person { int age = 20, weight 70; String hair_color = “black”; function getAge() { return age; } } Youtube/AwaisMirza
  • 15.
    Debugging Almost every timewhen we write code, we face problems. As the code gets larger, it becomes very difficult to find out problems. There are many ways to find (debug) the code for detecting problems. 1. IDE specific debugger 2. Manual debugging 3. Scenario Testing 4. Automated Testing 5. Test Driven Development Youtube/AwaisMirza
  • 16.
    What’s Next Check outmy Youtube Channel to learn actual programming with basics and project based tutorials. https://www.youtube.com/channel/UCIKbbV7ae7LAWa8cGnvjSPA Youtube/AwaisMirza