Saturday, November 20, 2010

Lets start Python Programming



It has been a while i want to try Python programming. Too much things to learn lately. Today try to start smthing with Python.
Downloaded Python2.7 from web.
Try Writing Hello world>>> it is D*** straight forward
...

Just write..... 'Hello world' .......in GUI .
it Prompts .... Hello world .......

Hello World is done>>>>

Lets start Maths>>>>

Type 1+2 in GUI Gives 3
Type 1*2 in GUI Gives 2
Type 1/2 in GUI Gives 0 .Y? later find out <-------
Type 1-2 in GUI Gives 3

Why not try 3%2 in GUI. It Gives 1 as expected.

let's search y 1/2 gives 0 rather than 0.5. How to do what i am suppose to get????
Try Type 1.0/2 in GUI Gives 0.5
Try Type 1/2.0 in GUI Gives 0.5


Hmm!!!! Understand. HoHoHo>>>>>>

What about precedent>>>>>


lets Try>>>>

so precedent is still in order of * / + -
But Y 7.19999999999999 instead of 7.2 ? <-----

That is!!! What the Heck????. Just use round() for watever u want . HoHoHo.
My head aching while reading python manual!!!!
Reference::: Python Manual

Let's try looping>>>>

Try with while loop

So syntax err if no ":" , NOTED!!!!


Lets try Calculator Program, Just +-*/,


And the output is

I can get 1/2=0.5 only if num1*1.0/num2 in the option4 .


Lets Study list now!

Program::
Results:::

so take note that index start from '0' as well in python.