Monday, April 24, 2017

C++ PROGRAM

Salam & welcome back guys!
How are you guys doing? we hope that you guys are doing fineπŸ˜ƒ

In this entry, we would like to share on the C++ program.  According to wikipedia, C++ is a general purpose programming language. Basically there are 6 basic elements in this program:


  1.  Simple C++ program
  • The simple C++ program is can be done at πŸ‘‰ click here and then choose C++ in the language search
  • The format and example is:
1 // Writing my age 
πŸ‘‰ 1st line is called comment line that describe the purpose of the program
πŸ‘‰ Must begin with //

3 #include <iostream>
πŸ‘‰ Is the processor directive
πŸ‘‰ Must begin with #
πŸ‘‰ <iostream> is the library of function, symbols and operators

4 using namespace std; 
πŸ‘‰ To give instruction to the compiler to use function in standard library.
6 int main() 
πŸ‘‰ The main function of the program

7 { 
πŸ‘‰ Code starts { 

8 int age; // input - age 
10 // Get data on age 

11 cout << "Enter your age => ";
πŸ‘‰ An interactive message which the program asking for data from the user as input data is called a prompt

12 cin >> age;
πŸ‘‰ The variable name has to be defined earlier

13 
14 //Display message 

15 cout << "I am " << age << " years old" << endl; 
πŸ‘‰ endl is used to terminate a line of output and starts a new one

16 return 0; 
πŸ‘‰ indicates that the program has ran normally

17 } 
πŸ‘‰ ends of the code

  • the coding is as shown below:


  • The input will be:

Enter your age =>  19
I am 19 years old
  

      2. Data Types
  • Numbers
- Floating point numbers
   πŸ‘‰ Numbers with fractional part or decimal place
- Integers
   πŸ‘‰ Exact numbers without decimal place

  • Characters
- Store single characters 
- Written as char
- The characters is enclosed in single quotes

  • Strings
- Double quotes is used to enclose a string’s value 

      3. Arithmetic expression
  • Multiple operators
- Parentheses of complex sub-expression. eg:
p / –q + ( r – s + t ) * n => ( p / (-q) ) + ( ( r – s + t ) * n )
 
  • Operators / and % 
- Calculate the integer quotient (/) & remainder (%)

  • Rounding
- If you want to round a positive value of the float to the nearest integer, add 0.5 before explicitly converting to an int to avoid loss of the value’s fractional part

      4. Additional Operators
- Besides, + - * / , C++ program also can provides predefined units called functions for operators 
- The list of names and descriptions of some of the most commonly used functions are as shown below:


Well, that's all  what we had learnt in the past class. Till then, thank you guys for constantly reading our blog!πŸ’‹πŸ˜˜



Friday, April 7, 2017

PYTHON & JUPYTER

Assalammulaikum w.b.t everyone and may all of you in the pink πŸ˜ƒ.

This is continuation of last lesson which is Python. So, before we discover more about python and jupyter, we learnt about the data types in python which are number, list, string, tuple and dictionary.

First of all, go to command prompt or cmd.

Second, just type in python. Later, proceed with variable which is the name and do not forget to put open and close quotes "" and hit the button "enter". To see the outcome, type print in the bracket the statement.
The result will become as below.

Next, to make data type for list, one should put the square bracket and with the list. After that, proceed with the print input.

Furthermore, the values stored in a list can be accessed using the slice operator ([] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1.


Lastly, to exit the command prompt put exit() 


Next, we learnt about jupyter. We will guide you to use jupyter.
1. First go to https://software-carpentry.org/ 
2. Click LESSON
3. Go to programming with python (site)
4. Click Setup and download python-novice-inflammation-data.zip
5. Back to programming with python and go to Analyzing Patient Data
6. Open jupyter, click upload and upload inflammation-01 from python-novice-inflammation-data.zip folder that you download just now
7.Click New, Python 3 and follow the instruction from analyzing patient data

You will get this as result

To move to next column, you need to press [shift] [enter]

You can continue follow the tutorial provide by analyzing patient data. Here are some example of result that you will get




For tutorial in plotting a graph or shape, you need to go to http://matplotlib.org/gallery.html, and choose the graph or shape you need then type the code on jupyter.

This is example:




You can change your data according to your preferences by changing the code. For example, change green to red so the graph produced will show you red colour instead of green colour.

That's all for today and hope you guys can gain something from this. Thank you.πŸ’“