RUVIDEO
Поделитесь видео 🙏

Modules in Python смотреть онлайн

📁 Обучение 👁️ 21 📅 02.12.2023

Modules in Python:

I received one project:
Client—project
Many persons will involve…to complete the project

1. Requirement analysis
2. Client-meet---requirement:
3. SRS
4. Design

#Modules example: Arithmetic Modules
#arith.py
def add(a,b):
return a+b
def sub(a,b):
return a-b
def mul(a,b):
return a*b
def div(a,b):
return a/b
Save the above program as “arith.py”
Go to same folder (Ex: Caliculator) and write another program to use the function of other module.
import arith
a=int(input("enter a value:"))
b=int(input("enter b value:"))
c=arith.add(a,b)
d=arith.sub(a,b)
e=arith.mul(a,b)
f=arith.div(a,b)
print("Addition of two nos:",c)
print("Sub of two nos:",d)
print("Mul of two nos:",e)
print("div:",f)

"""
Output:
enter a value:8
enter b value:4
Addition of two nos: 12
Sub of two nos: 4
Mul of two nos: 32
div: 2.0
"""
save this program with any name.py, Ex: test.py

literals
statements
functions: collection of statements which performs a specific task is called function
modules: collections of functions, classes and variables which are saved into a file, which is nothing but a module

Two types of modules:
1. Predefined/built in modules:
Sys,io, functools,math,…etc
2. User defined module
Which means we are defining our own module, so that we can use wherever it is required, simply by importing the module name, call the function.

#If you want to use arith.py module in another directory
import sys
sys.path.append("F:\Programs\Caliculator")
import arith
a=int(input("enter any two nos"))
b=int(input("enter any two nos"))
c=arith.add(a,b)
print("addition of two numbers are:",c)

"""
enter any two nos8
enter any two nos4
addition of two numbers are: 12
"""
#If you want to use arith.py module in another directory
We can use from module_name(file.py)import functionanmes,func2,…
import sys
sys.path.append("F:\Programs\Caliculator")
#import arith
from arith import add,div
a=int(input("enter any two nos"))
b=int(input("enter any two nos"))
#c=arith.add(a,b)
c=add(a,b)
print("addition of two numbers are:",c)

"""
enter any two nos8
enter any two nos4
addition of two numbers are: 12
"""

Example2:
#module1.py
n=20
def add(a,b):
print(a+b)
def mul(a,b):
print(a*b)
module1 contains one variable i.e n, and two functions (add(),mul())

I want to use the above members (var,fun,class) in another program in same folder.
Steps:
1. First we need to ‘import the module’
Ex: import module1
2. We can access members by using module name.
Example: modulename.member
module1.n
module1.add(2,3)
module1.mul(4,5)

Renaming the module:
#renaming a module
import module1 as m
print(m.n)
m.add(2,3)
m.mul(2,3)
"""
20
5
6
"""
From..import
We can import the modules, and its members by using from…import keywords.

Main use of from..import , directly we can access members of modules.
Ex:
#from..import
from module1 import n,add,mul
print(n)
add(2,3)
mul(2,3)
"""
20
5
6
"""

We can import all members of a modules by using following way:
from module1 import*
print(n)
add(2,3)
mul(2,3)
"""
20
5
6
"""

If you want to use the other program’s functions, variables, classes in another program:
import module
import module1,module2,module3,module4,….
import module1 as m
Renaming Multiple modules :
Import module1 as m, module2 as m1, module3 as m2,..
Without using module name, directily we can call the members of modules:
From module1 import add,n,mul
#all the members can be accessed by using *
From module1 import*

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Modules in Python» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.