Blogger Themes

Search This Blog | Copyright © 2017 | All Rights Reserved | Nithin Pradeep . Theme images by Storman. Powered by Blogger.

Follow by Email

Popular KOZHI



Blogger Tricks


What is an Embedded System?

An embedded system is a combination of hardware and software that is designed to carry out a certain task or tasks, meaning it has a s...


Popular Posts


Search results

Search This Blog


More Links




Friday, 25 August 2017

Creating Modules in Python

In this section we will discuss how to create module in Python...

what is a module?

module is a Python object with arbitrarily named attributes that you can bind and reference. Simply, a module is a file consisting of Python code. A module can define functions, classes and variables. A module can also include runnable code.

See the following program

We are creating 2 modules one for ( operations like add,subtract,... and other for finding power(
The program will prints output as

in shell....

A pyc file is created after impporting..
We have to create .pyc file for security purposes since in python application it self is cource code.It is automatically created for modules and packages but not for normal files,
else we can create like this.
python -m py_compile
this p2.pyc is called as byte code or frozen binary.


 l.reverse(l.sort) - will print list in reverse order
>>> l
[1, 2, 3, 60, 4, 5, 6, 500, [100, 200, 300]]

this will append whole list

>>> l.extend(subl)
>>> l
[1, 2, 3, 60, 4, 5, 6, 500, [100, 200, 300], 100, 200, 300]

this will append only list elements as individual,ie it needs itrative items

l.append(123) works but l.extend(123) will give error.
 l.pop() will pop data from list and will give return value also.

 l.remove(3)- removes first occurance of 3.
lets see..
Write a program to delete all occurance of given number from list.

l1=l implies that l1 is reference to l.
del command will delete a perticular member .

  • how to print a perticular character from a print 't' and [20,30] from [10,'Nithin',20,[10,20,30]]  

in the next section we will discuss about list comprehension...

<<previous                                                                                                                                Next>>

0 on: "Creating Modules in Python"