Friday, December 2, 2016

Python beginner first class

Python is an Interpreted language. Wait a minute! what is an interpreted language?

Interpreted language:
---------------------------

# Interpreted is not the property of Programming language rather it's a property of implementation.

# Interpreted language fully depends on language implementation.

# An Interpreted language like python, a ruby that's language implementation execute instruction directly.

# In Interpreted language code run line by line.So that's why python runs the code line by line.

#Python will fall under bytecode interpreted.

# .py source code at first complied at bytecode .pyc.  This bytecode can be interpreted by official CPython.




That's it.Now open your Interactive shell. If you are in windows go to start and write python and open IDLE(python GUI).


I am using Python 2.7.6 shell. 



Now Let's get start coding.

So our first program:

"Hello world"


press enter and it will show 'Hello world'

2nd program:

print "Hello Python"

output:

Hello Python

Carefully note that first program output give us single quotation and second program only Hello Python because we write a print function in the second program.

Later we talk about function

so, In python, if you want your output without quotation you can use print .

3rd program:
------------------

>>> 1+1
2

>>> 3 * 2
6

>>> 8 - 2
6

>>> 9 / 3
3

>>> 10/3
3

oh, wait. I think you are wrong.where ? 10/3 = 3.33. Hm, write but python

interpreter shows 3. why?

Because 10 and 3 are an integer. That's why interpreter gives the answer integer 3.

But if we define Real number like this:

>>> 10.0 / 3
3.3333333333333335

see output came real number.


Here is the screenshot.
























That's it for today. 



Thanks.



Tips:
---------

practice interactive mode.As much as you practice you quickly learn, if any mistake please comment.




No comments:

Post a Comment