0% found this document useful (0 votes)
0 views17 pages

Python Package

Uploaded by

shelarsiddhi59
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views17 pages

Python Package

Uploaded by

shelarsiddhi59
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

𝙋𝙔𝙏𝙃ON

𝘽U𝙄L𝘿-
𝙋𝘼𝘾𝙆𝘼GES
𝙄N
Presented by Saniya sawardear & Riya
1
mohite
INTRODUCTION

𝙋𝙮𝙩𝙝𝙤𝙣 𝙣𝙞𝙘𝙪𝙡𝙙𝙚𝙨 𝙖 𝙫𝙖𝙨𝙩 𝙘𝙤 𝙚


𝙡𝙘𝙤
𝙩𝙞𝙣 𝙤𝙛 𝙗𝙪𝙩𝙡𝙞 -𝙞𝙣 𝙥𝙖𝙘𝙠𝙖𝙜𝙚𝙨, 𝙠𝙣𝙤𝙬𝙣 𝙨𝙖 𝙩𝙝𝙚 S𝙩𝙖𝙣𝙙𝙖𝙧𝙙 L𝙗 𝙞𝙧𝙖𝙧𝙮, 𝙬𝙝𝙞𝙘𝙝 𝙥𝙧𝙤𝙫𝙙
𝙞𝙚𝙨 𝙢𝙤𝙙𝙪𝙡𝙚𝙨
𝙖𝙣𝙙 𝙛𝙪𝙣𝙘𝙩𝙤
𝙞𝙣𝙨 𝙤 𝙛𝙧 𝙘𝙤𝙢𝙢𝙤𝙣 𝙥𝙧𝙤𝙜𝙧𝙖𝙢𝙢𝙞𝙣𝙜 𝙩𝙖𝙨𝙠𝙨.
𝙏𝙝𝙚𝙨𝙚 𝙥𝙖𝙘𝙠𝙖𝙜𝙚𝙨 𝙘𝙤𝙫𝙚𝙧 𝙖𝙧𝙚𝙖𝙨𝙠 𝙞𝙚
𝙡𝙚𝙡𝙞𝙛𝙄/𝙊, 𝙙𝙖𝙩𝙖 𝙢𝙖𝙣𝙥 𝙞𝙪𝙖
𝙡𝙩𝙤
𝙞𝙣, 𝙣𝙚𝙩𝙬𝙤𝙧𝙠𝙞𝙣 𝙜, 𝙖𝙣𝙙 𝙢𝙤𝙧𝙚,
𝙝𝙚𝙥𝙡𝙣
𝙞𝙜 𝙙𝙚𝙫𝙚𝙤𝙡𝙥𝙚𝙧𝙨 𝙥𝙚𝙧𝙛𝙤𝙧𝙢 𝙩𝙖𝙨𝙠𝙨 𝙬𝙩𝙞𝙝𝙤𝙪𝙩 𝙣𝙚𝙚𝙙𝙞𝙣𝙜 𝙚𝙭𝙩𝙚𝙧𝙣𝙖𝙡 𝙙𝙚𝙥𝙚𝙣 𝙙𝙚𝙣𝙘𝙞𝙚 𝙨. 𝙏𝙝𝙚
𝙋𝙮𝙩𝙝𝙤𝙣 S𝙩𝙖𝙣𝙙𝙖𝙧𝙙 L𝙗 𝙞𝙧𝙖𝙧𝙮 𝙨𝙞 𝙗𝙪𝙣𝙙𝙡𝙚𝙙 𝙬𝙩𝙞𝙝 𝙋𝙮𝙩𝙝𝙤𝙣, 𝙨𝙤 𝙣𝙤 𝙣 𝙤
𝙖
𝙞𝙨
𝙞𝙖
𝙡𝙣
𝙩𝙡 𝙨𝙞 𝙧𝙚𝙦𝙪𝙧𝙞𝙚𝙙 𝙩𝙤 𝙪𝙨𝙚
𝙩𝙝𝙚𝙨𝙚 𝙥𝙖𝙘𝙠𝙖𝙜𝙚𝙨.

2
US𝙄NG 𝙋𝙔𝙏𝙃ON 𝘽U𝙄L𝘿-𝙄N 𝙋𝘼𝘾𝙆𝘼GES:
Python comes with a variety of built-in libraries, often referred to as the standard library. These
libraries provide functionalities for various tasks, such as handling file operations, interacting with the
operating system, data manipulation, and much more. Below is an overview of the most commonly
used built-in packages and modules available in Python:

1.𝙤𝙧
𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Interacting with the operating system
F𝙪𝙣𝙘𝙩𝙞𝙤𝙣: File and directory manipulation, process management, environment etc variables,
E𝙭𝙖𝙢𝙥𝙡𝙚:
Import os
os.mkdir("new_folder") # Creates a new directoryos remove ("file.txt") # Removes
a File

3
2.𝙨𝙮𝙨

𝙋𝙪𝙧𝙥𝙤𝙨𝙚:Interfacing with the python runtime environment

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣: Handling command -line arguments,interacting with the interpreter,managing paths, etc.

E𝙭𝙖𝙢𝙥𝙡𝙚:
𝙄mport sys
Print(sys.argv) # List of command-line arguments sys.exit(0) # Exit the program

3. 𝙢𝙖𝙩𝙝

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: mathematical functions.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨: mathematical operations like trigonometry, logarithms,powers, etc.

E𝙭𝙖𝙢𝙥𝙡𝙚:
𝙄mport math
Print(math.sqrt(16)) # Output: 4
4.0
4.𝙧𝙖𝙣𝙙𝙤𝙢

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Generating random numbers.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨: Random number generation, shuffling, choosing random elements from a list, etc

E𝙭𝙖𝙢𝙥𝙡𝙚

import random
print(random.randint(1.10)) # Random number between 1 and 10 print (random.choice([1,2,3,4])) # Random choice from a
list

5.𝙙𝙚𝙩𝙚𝙩𝙢
𝙞𝙚

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Working with dates and times

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣: Date arithmetic,formatting dates, timezone handling, etc.

E𝙭𝙖𝙢𝙥𝙡𝙚
import datetime
print(datetime.datetime.now()) # Get the current date and 5
time print(datetime.date.today()) # Get today's date
6.𝙧𝙚

𝙋𝙪𝙧𝙥𝙤𝙨𝙚 Regular expressions for pattern mathod


𝙞𝙣 Searching,
𝙛𝙪𝙣𝙘𝙩𝙤
replacing, and splitting strings based on regular expressions.

E𝙭𝙖𝙢𝙥𝙡𝙚:
import re
Pattern = r"\
d+"
text = "There are 123 apples" result = re.findall(pattern,
text) print(result) # Outputs: ['123']

7.𝙨
𝙟𝙤𝙣

𝙋𝙪𝙧𝙥𝙤𝙨𝙚 JSON (JavaScript Object Notation) data manipulation.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣 Parse JSON, serialize data to JSON,etc.


E𝙭𝙖𝙢𝙥𝙡𝙚:
mport JSON
data = {'name':'John','age':30}
json_data = json.dumps(data) # Convert to JSON
string print(json_data) 6
8. 𝙤𝙨.
𝙋𝙖𝙩𝙝
𝙋𝙪𝙧𝙥𝙤𝙨𝙚 path manipulation (file system).

𝙛𝙪𝙣𝙘𝙩𝙞𝙤𝙣Joining paths, checking file existence, file extensions,etc.

E𝙭𝙖𝙢𝙥𝙡𝙚
Import os.path
print(os.path.exists("file.txt")) # Check if file
exists print(os.path.join("folder","file.txt")) # Join
paths

9. 𝙩𝙢
𝙞𝙚

𝙋𝙪𝙧𝙥𝙤𝙨𝙚 Time-related functions

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨: Sleeping, time measurement,


converting
E𝙭𝙖𝙢𝙥𝙡𝙚 time formats, ect.
7
Import time
print(time.time()) # Current time in seconds since the epoch time.sleep(2) # Sleep for 2
10.𝙚
𝙩𝙞𝙤
𝙧𝙩𝙤𝙡

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Function for creating iterators for efficient looping. F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨

Generating permutations, combination, count, cycle, ect. E𝙭𝙖𝙢𝙥𝙡𝙚:

import itertools
print(list(itertools.permutation([1,2,3,]))) # All permutations

11.𝙛
𝙪𝙣𝙘𝙩𝙤𝙤𝙨
𝙡

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: High-order functions for functional programming tasks.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣 Caching results, function decorations, partial functions, etc.

E𝙭𝙖𝙢𝙥𝙡𝙚

import functools
def add(x, y):
return x + y
add_five = 8
functools.partial(
add, 5)
12.𝙘𝙤
𝙚
𝙡𝙘𝙤
𝙩𝙞𝙣𝙨

𝙋𝙪𝙧𝙥𝙤𝙨𝙚 Specialized container datatypes.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨: Named tuples, defaultdict, deque, Counter, ect.


E𝙭𝙖𝙢𝙥𝙡𝙚
from collections import Counter
counter = Counter([1, 2, 2, 3, 3,
3])
print(counter) # Outputs:
Counter({3: 3, 2: 2, 1: 1})

13.𝙘𝙨𝙫

𝙋 𝙪𝙘𝙩𝙤
𝙛𝙪𝙣 𝙧𝙞𝙥 𝙚: Reading
𝙣𝙤𝙨Handling from
CSV fileand
format in a structured way.
writing
E𝙭𝙖𝙢𝙥𝙡𝙚to : CSV files.
Import csv
with open('data.csv', mode='r') as
file: csv_reader = csv.reader(file)
for row in 9
csv_reader:
print(row),
14. 𝙨𝙤𝙘𝙠𝙚𝙩

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Networking interface (communication between computers).

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨: Create sockets, send/receive data over the network, etc.

E𝙭𝙖𝙢𝙥𝙡𝙚
mport socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('example.com', 80))

15. 𝙝𝙩𝙥

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Handling HTTP requests and responses.

𝙈𝙤𝙙𝙪𝙡𝙚𝙨: http.client, http.server, http.cookiejar,


http.cookies.
E𝙭𝙖𝙢𝙥𝙡𝙚𝙨
From http.client import HTTPConnection
conn = HTTPConnection("www.example.com
") conn.request("GET", "/") 10
16. 𝙖𝙧𝙜𝙥𝙖𝙧𝙨𝙚

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Parsing command-line arguments.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨 Handling arguments passed when running the script.

E𝙭𝙖𝙢𝙥𝙡𝙚

import argparse
parser = argparse.ArgumentParser(description="A simple argument
parser") parser.add_argument("name", help="Name of the user")
args = parser.parse_args()
print(f"Hello, {args.name}")

17. 𝙥
𝙘
𝙞𝙠
𝙚
𝙡

𝙋𝙪𝙧𝙥𝙤𝙨𝙚: Serializing and


deserializing Python
objects.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣 Saving Python


objects to files and
loading them back.
import pickle
data = {"name": "John", "age":
E𝙭𝙖𝙢𝙥𝙡𝙚
30} with open("data.pickle", "wb")
as f:
1
pickle.dump(data,f)
1
18.𝙨𝙝𝙪
𝙣
𝙞𝙩𝙡

𝙋𝙪𝙧𝙥𝙤𝙨𝙚 High-level file operations (copying, moving, etc.).

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨 Copy files, delete directories, etc.

E𝙭𝙖𝙢𝙥𝙡𝙚

import shutil
shutil.copy("source.txt", "destination.txt") # Copy a file

19.𝙥𝙖
𝙡𝙩𝙛𝙤𝙧𝙢

𝙋𝙪𝙧𝙥𝙤𝙨𝙚 Accessing information about the operating system.

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣 Get system details, such as OS type, version, and architecture.

E𝙭𝙖𝙢𝙥𝙡𝙚

import platform
1
print(platform.system()) # Outputs the OS type (e.g.,
2
'Windows')
20. 𝙩𝙝𝙧𝙚𝙖𝙙𝙣
𝙞𝙜

𝙋𝙪𝙧𝙥𝙤𝙨𝙚 Multi-threading support (concurrent execution).

F𝙪𝙣𝙘𝙩𝙞𝙤𝙣𝙨 Creating and managing threads for parallel execution.

E𝙭𝙖𝙢𝙥𝙡𝙚

import
threading def
print_hello():
print("Hello
from thread!")
thread = threading.Thread(target=print_hello)
thread.start()

1
3
INSTALLING PACKAGES USING PIP :
To install packaoftes usinoft pip, follow this
step:-

1.open your terminal Or command Prompt:

2.Run the pip install command:

For installing a single package,

type: pip install <package-name>

Example:

pip install 1
4
requests
3.𝙄𝙣𝙨𝙩𝙖𝙡 𝙖 𝙨𝙥𝙚𝙘
𝙛𝙞 𝙫𝙚𝙧𝙨𝙤
𝙞𝙣 𝙤𝙛 𝙖 𝙥𝙖
𝙖𝙜𝙚
𝙠𝙘 𝙨:

If you need to install a particular version,


use:

pip install <package-name>==<version>

E𝙭𝙖𝙢𝙥𝙡𝙚:

pip install requests==2.25.1

4. 𝙄𝙣𝙨
𝙖
𝙩𝙡𝙡 𝙢𝙪𝙥
𝙩𝙞𝙡𝙚
𝙡 𝙥𝙖𝙘𝙠𝙖𝙜𝙚𝙨 𝘼𝙩 𝙤
𝙣𝙚𝙘:

You can list them all in one


command:
pip install requests numpy 1
5
pandas
5. 𝙄𝙣𝙨
𝙖
𝙩𝙡𝙡 𝙛𝙧𝙤𝙢 𝙖 𝙧𝙚𝙦𝙪𝙧𝙞𝙚𝙢𝙚𝙣𝙩𝙨. 𝙭
𝙩𝙩𝙚:
𝙡𝙞𝙛

If you have a requirements.txt file (common for project dependencies), you can install all
the packages listed in it:

pip install -r requirements.txt

6. 𝙐𝙥𝙜𝙧𝙖𝙙𝙚 𝙖𝙣 𝙚𝙭
𝙨
𝙞𝙣
𝙩𝙞𝙜 𝙥𝙖𝙘𝙠𝙖𝙜𝙚𝙨:

If you need to upgrade a package to the latest

version: pip install --upgrade <package-name>

E𝙭𝙖𝙢𝙥𝙡𝙚:

1
pip install --upgrade 6
requests
𝙏𝙝𝙖𝙣𝙠
𝙔𝙤𝙪
1
7

You might also like