0% found this document useful (0 votes)
3 views4 pages

PackageFile Plot

The document outlines the creation of a package containing five modules (fish, birds, amphibians, mammals, reptiles), each with functions to display examples and characteristics of the respective animal groups. It also describes file operations such as reading, appending, checking existence, and deleting files, along with counting words in a file. Additionally, it includes programs for plotting scattered points and lines using matplotlib.

Uploaded by

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

PackageFile Plot

The document outlines the creation of a package containing five modules (fish, birds, amphibians, mammals, reptiles), each with functions to display examples and characteristics of the respective animal groups. It also describes file operations such as reading, appending, checking existence, and deleting files, along with counting words in a file. Additionally, it includes programs for plotting scattered points and lines using matplotlib.

Uploaded by

sclcvp
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Package

Create a package which contains five modules fish, birds, amphibians, mammals, and reptiles. Each
module contains two functions example and characteristics.

[Link]
def examples():
print("Here are some examples of amphibians:")
egs=['Frog',"Salamander","Toads","Newts","caecilians"]
for f in egs:
print(f)
def chars():
ch=["Cold blooded","Lays eggs","Moist scaleless skin"]
print("Characteristics of amphibians:")
for c in ch:
print(c)

[Link]
def examples():
print("Here are some examples of birds:")
egs=['Parrot',"Pigeon","Crow","Owl","Sparrow"]
for f in egs:
print(f)
def chars():
ch=["Have wings","Lays eggs","Warm blooded","Have beaks and no teeth"]
print("Characteristics of birds:")
for c in ch:
print(c)

[Link]
def examples():
print("Here are some examples of fish:")
egs=['Goldfish',"Tuna","Guppy","Piranha","Swordfish"]
for f in egs:
print(f)
def chars():
ch=["Lives Under Water","Breathes through gills","Swims using fins and Tail"]
print("Characteristics of fish:")
for c in ch:
print(c)

[Link]
def examples():
print("Here are some examples of mammals:")
egs=["Human","Cat","Tiger","Dog","Elephant"]
for f in egs:
print(f)
def chars():
ch=["Warm blooded","Gives birth to babies","Have hair and fur","Four chambered heart"]
print("Characteristics of mammals:")
for c in ch:
print(c)

[Link]
def examples():
print("Here are some examples of reptiles:")
egs=['Turtle',"Lizard","Crocodiles","Chameleon","Snakes"]
for f in egs:
print(f)
def chars():
ch=["Have scales","Vertebrates","Breathe through lungs","Cold blooded"]
print("Characteristics of reptiles:")
for c in ch:
print(c)

[Link]
import fish,birds,amphibians,mammals,reptiles
def __init__(self):
print("Find your information about creatures:examples and characteristics")

[Link]
#Creatures package includes various modules
import Creatures
print("Find your information about creatures:examples and characteristics")
while(1):
print("Press\n1 for fish\n2 for birds\n3 for amphibians\n4 for mammals\n5 for reptiles\n6 to exit:")
c=int(input())
if c==1:
Creatures. [Link]()
Creatures. [Link]()
elif c==2:
Creatures. [Link]()
Creatures. [Link]()
elif c==3:
Creatures. [Link]()
Creatures. [Link]()
elif c==4:
Creatures. [Link]()
Creatures. [Link]()
elif c==5:
Creatures. [Link]()
Creatures. [Link]()
elif c==6:
print("Thank You!!!")
break
else:
print("Wrong input")

#for each module class concept has been introduced purposefully.


#to be noted same process can be implemented without introducing separate class

File
Write a file. Read the file and print its content. Read first two lines. Read first 5 characters. Read the
file using loop.
[Link]
Hello! Welcome to [Link]
This file is for testing purposes.
Good Luck!

f = open("[Link]", "r")
print([Link]())
[Link](0)
print([Link]())
print([Link]())
[Link](0)
print([Link](5))
[Link](0)
for x in f:
print(x)
[Link]()

Append content in the above mentioned file.


f = open("[Link]", "a")
[Link]("Now the file has more content!")
[Link]()
#open and read the file after the appending:
f = open("[Link]", "r")
print([Link]())

Check whether a file exists or not. Delete it.


import os
if [Link]("[Link]"):
[Link]("[Link]")
else:
print("The file does not exist")
Count the number of words in a file.
words=0
with open(“[Link]”,’r’) as f:
for line in f:
w=[Link]()
words+=len(words)
max_len=len(max(w,key=len))
print(words)

Plotting

Write a program to plot scattered points.


import [Link] as plt
def draw_multiple_points():
x_number_list = [1, 4, 9, 16, 25]
y_number_list = [1, 2, 3, 4, 5]
[Link](x_number_list, y_number_list, s=10)
[Link]("Extract Number Root ")
[Link]("Number")
[Link]("Extract Root of Number")
[Link]()
if __name__ == '__main__':
draw_multiple_points()

Write a program to plot using lines.


import [Link] as plt
x=[1,2,3]
y=[2,4,1]
[Link](x,y,label='l1')
x=[1,2,3]
y=[8,6,9]
[Link](x,y,label='l2')
[Link]("x-axis")
[Link]("y-axis")
[Link]()
[Link]()

You might also like