Feeds:
Posts
Comments

Posts Tagged ‘Programming Language-Python’

What is method?
In programming language, method is something that you do to an object.

For example, the object is ‘door‘ and you want to apply an action ‘open‘.

In python you can write as: door.open().

door = object

open = method

( ) = argument

Argument is the place for parameters that you apply to the method.

For example, you want to open your door half only or full open then changing the color painting to blue or red.

The syntax will be:

door.open(‘half)

door.open(‘full‘)

door.color(‘blue‘)

door.color(‘red‘)
In python, you can use built-in methods or create it manually.

Let me explain more details.
(more…)

Read Full Post »

If Statement is a conditional that python will check before taking a new action. If statement result is TRUE, python will process the command given otherwise it will ignore and execute the next step.

The syntax is:
if statement:
your_command

Let’s try.
—————————————————————
>>> myprogramming_language=’python’
>>> if myprogramming_language==’python':
print “Python is my programming language”

Python is my programming language
>>>
—————————————————————

myprogramming_language=’python’ will tell python, please enter variable myprogramming_language with value python.

if myprogramming_language==’python': will tell python, if myprogramming_language is equal with ‘python’ then execute the next line, otherwise just ignore and continue to the next step.

If it’s equal mean the condition is True.

If it’s not equal the condition is False.


(more…)

Read Full Post »

Strings is one or more combination of alphabet. Python will recognize double colon(“ ”) or single colon (‘ ‘) for string declaration.

For example, to declare ‘This is a string‘ as string, you can use double colon or single colon.

——————————-
>>> “This is a string”
‘This is a string’
>>> ‘This is a string’
‘This is a string’
>>>
——————————-

Very easy. How about to write Hii… I’m python. There is one single colon in the string.

You can’t write, ‘Hi.. I’m python’ because python will confuse to set the beginning and the end of the string because single colon in (I’m) will consider as end of string content.
——————————-
>>> “I’m python”
“I’m python”
>>> ‘I’m python’
SyntaxError: invalid syntax
>>>

But, with “double colon is fine.

——————————-
>>> “I’m python”
“I’m python”
——————————-

(more…)

Read Full Post »

Function is a built-in program that available in Python that we can use to simplify our programming code. Mostly every programming language provide their built-in function according to purpose why it’s created. Functions in C, python, pearl, vb, assembly will be different.

To use function in python, you have to write the function name then followed by the parameters that the function need. Parameter is the information that will be used by function to solve the problem.

Built-in Functions:
abs(), divmod(), input(), open(), staticmethod(), all(), enumerate(), int(), ord(), str(), any(), eval() isinstance(), pow(), sum(), basestring(), execfile(), issubclass(), print(), super(), bin(), file(), iter(), property(), tuple(), bool(), filter()
,len(), range(), type(), bytearray(), float(), list(), raw_input(), unichr(), callable(), format(), locals(), reduce(), unicode(), chr(), frozenset(), long(), reload(), vars(), classmethod(), getattr(), map(), repr(), xrange(), cmp(), globals(), max(), reversed(), zip(), compile(), hasattr(), memoryview(), round(), __import__(), complex(), hash(), min(), set(), apply(), delattr(), help(), next(), setattr(), buffer(), dict(), hex(), object(), slice(), coerce(), dir(), id(), oct(), sorted(), intern()

(more…)

Read Full Post »

What is Python?

Python is a dynamic programming language that combine great power with very clear syntax. Guido Van Rossum began to work with python in late 1980 at National Research Institute for Mathematics and Computer science in Netherland (CWI). Before I read the history, I though it came from name of snake. But I was wrong. Guido named it when he saw ‘Monthy Python’s Flying Circus‘ comedy TV show in BBC.


Write your own first syntax

Well, no need to explain more details about python, you can find it in the Internet. Just let’s start.
Open Linux Terminal (Applications > Accessories > Terminal) then type: python.
You will get ‘>>>>’ prompt. It’s mean that python is ready to get any commands.

(more…)

Read Full Post »

Follow

Get every new post delivered to your Inbox.

Join 76 other followers