0% found this document useful (0 votes)
5 views

python presentation 1

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

python presentation 1

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Good morning sir myself pranav reddy from cse

Today we are going to discuss about the module structure of python


These are the topics that are covered in this ppt

The main reasons why we should study these topics are the following:
1. Efficient use of functions created by others
2. Proper structures when you are creating your own python solutions for problems

Standard library is a set of skills that python has by default,,,

so when it needs to perform the tasks which it is not good at then it relies on modules and
packages. And by using help(modules) command we can get the built in modules of python
these are some of the modules
Now, let’s discuss some of the useful and frequently used built-in modules of Python.
Math Module and statistics module Some of the most popular mathematical functions that are
defined in the math module include,
 Trigonometric functions,
 Representation functions,
 Logarithmic functions,
 Angle conversion functions, etc.
In addition, two mathematical constants- pi and e are also defined in this module.
And in statics module the following popular statistical functions are defined
 Mean
 Median
 Mode
 Standard Deviation

Now we will take a look at an example of how modules work.


So here addition,subtraction,multiplication and division operators are made into different functions
And these all functions reside inside a python file arithmetic.py so this file is called a module.

Packages are nothing but the collection of modules.

So this about the standard libraries,modules and packages,now we will discuss about the module
search path,

To import any module we will use import function, when we use this function
The interpreter searches for the file
o In the current directory
o In the PYTHONPATH environment variable list of directories
O The directories configured as part of your Python installation
The module search path is stored in the system module sys as the sys.path variable. The
sys.path variable contains the current directory, PYTHONPATH, and the installation-
dependent default.

The PYTHONPATH is an environment variable, consisting of a list of directories. The syntax


of PYTHONPATH is the same as that of the shell variable PATH.

Now we use the dir function to check the modules present in the system ,

The dir() built-in function returns a sorted list of strings containing the names defined by a
module.
The list contains the names of all the modules, variables and functions that are defined in a
module. THIS THE simple example :
This is how we will import a module

And now we will discuss the points which are helpful in writing python codes such
that other programmers can easily understand our code.

So exactly why do we have to Code Effectively?

In our beginner stages as programmers, we tend to develop habits that enable us to receive
the solution to a particular program or task in the easiest manner possible. However, it can be
questioned whether obtaining the answer in this easy fashion is the most efficient and
effective method to computing the following problem.

Let us assume a simple example to print a statement called “Hello” with


a print statement five times. There are numerous ways to accomplish this
task. We will look at three such approaches that you can utilize for
performing the same code and analyse how effective they are and how
different each one of the following works.

The first approach is to print the statement five times.


Image

The second approach is to print the statement once and use a multiplier
to receive the desired output.
Image

The final approach that we will look at is to make use of a for loop for
performing this action.
Image

It is easy to deduce that you can complete a particular


program in multiple ways. In addition, it is vital that the
programmer makes the code he needs as readable as possible
in order to produce good results.

Additionally, documentation of code must be effective.

Documenting your code is one of the best practices to follow when


starting out. While programming, it is common to get caught up in
your world of code in search of the perfect solution to whatever
problem or project you are encountering.

Without proper documentation and understanding of the type of purpose


of the particular code blocks or pieces of code, it becomes nearly
impossible to determine what the exact task you are trying to accomplish
was. But more importantly, how exactly were you trying to accomplish it.

Hence, with effective documentation, not only do you help yourself who is
reading the code after a long time, but you also help other people who
want to read and understand your code. So, it is a good practice to input
some lines of comments explaining the purpose of the codes, especially
when publishing on a platform for others to view the code.

These are the few approaches of effective documentation ( image)

You might also like