Saturday, 8 April 2017

Phyton for Beginner

Assalamualaikum and hi there :)

In previous class, we were asked to do a kind of study group in class regarding this topic which is called Phyton. If you guys do not have any idea about what is Phyton, kindly refer to our previous post. 😉



What? you still cant get it? 

Hehe, don't worry. In our class last Tuesday, Dr KB had taught us the right way to use it. and now...
We will share it to you guys!

First and foremost, why we use Phyton instead of other languages such as Lisp, C, or Java?
This is because Phyton is :


  • Easy to use
  • Easy to learn (good choice for beginner)
  • Readability (not waste time understanding mysterious syntax)
  • Powerful & versatile ( companies like Google, Dropbox, Spotify, and Netflix use it)
  • Minimal setup
  • Powerful libraries
  • Free and open source software, widely spread, with a vibrant community

So, when you installed miniconda or conda, Jupyter will come together.

Phyton Notebook

Here is the link to download Miniconda for less space laptop or computer

Lets get started!

Open Phyton and type "Phyton" to know your Phyton version in your computer.

For Multiple Assignment

-Phyton allows you to assign a single value to several variables simultaneously.  
For example: a=b=c=1
-You can also assign multiple objects to multiple variables. 
For example: a,b,c = 1,2, "zabirah"  *refer to diagram 1.1

For Phyton list

-A list contains items seperated by commas and enclosed within square brackets ([]).

For example:
course= ['biotech', 'chemistry' , 'plantsc' ]
The first course represent 0,1,2 and onwards.


For Phyton String

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


When you type print (course[0:1] )
it will only appeared ['biotech'] . 
This is because second number which is 1 will be minus 1 and become 0. 
The first course written is 0 
*refer to diagram 1.1 for other examples.

It also can be written print (course [-1]) to represent the last course written, 
print (course [-2]) for second last, and so on.

You also can change the course name by typing course [number of position you want to change]  
For example course [2]= 'physics'
Then, plantsc will be replaced with physics.

To add course, type course.append ('cts')
and to delete, type course.pop (2) or delete course [1]


Diagram 1.1

For Phyton Tuples

-A tuple is another sequence of data type that is similar to the list. 
-A tuple consist of a number of values seperated by commas. 
-Unlike list, however, tuples are enclosed within parentheses and cannot be updated (read-only list)

Next, open your jupyter notebook,
then type conda --version, wait for the system to finish typing, type conda update conda, 
after that, type y, type conda create --name plantsc phyton =3, wait.
activate plantsc and lastly jupyter notebook

This is what we have done

 
                     


For the using of Jupyter Notebook

First, search Software Carpentry at google, click Lesson > Programming with Phyton (site) > setup. It will appear like this. Follow the instruction to download file.



Then, search Jupyter Notebook > Upload (file that you download just now)  
Instead of clicking on setup, go to Episodes > Analyzing Patient Data. A lot of powerful, general tools are built into languages like Phyton, specialized tools built up from these basic units live in libraries that can be use upon needed. So, here is the screenshot of what we have tried.

Hope it helps !










Fuhh, today's entry quite tough right 😓
But trust me, if you try to use it, its kind of exciting hehe
GOOD LUCK! 

No comments:

Post a Comment