100% found this document useful (1 vote)
93 views1 page

Mock Pra 3 Solution Python

This document defines two classes - Image and Album. The Image class represents images with attributes like ID, name, coordinates and type. The Album class represents an album containing a list of images. It has a method to calculate and return filtered images of a given type from the album after applying a filter percentage to their coordinates. The code at the end tests this functionality by creating sample Image objects, adding them to an Album, and calling the Album method to filter and return matching images.

Uploaded by

Siva Karthick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
93 views1 page

Mock Pra 3 Solution Python

This document defines two classes - Image and Album. The Image class represents images with attributes like ID, name, coordinates and type. The Album class represents an album containing a list of images. It has a method to calculate and return filtered images of a given type from the album after applying a filter percentage to their coordinates. The code at the end tests this functionality by creating sample Image objects, adding them to an Album, and calling the Album method to filter and return matching images.

Uploaded by

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

class Image:

def __init__(self,image_id,image_name,x_coordinates,y_coordinates,image_type):
self.image_id = image_id
self.image_name = image_name
self.x_coordinates = x_coordinates
self.y_coordinates = y_coordinates
self.image_type = image_type

def apply_filter(self,number):
self.x_coordinates = self.x_coordinates + self.x_coordinates*(number/100)
self.y_coordinates = self.y_coordinates + self.y_coordinates*(number/100)

class Album:
def __init__(self,album_name,img_list):
self.album_name = album_name
self.img_list = img_list

def calculate_coordinates(self,fpercent,imgtype):
l=[]
for i in self.img_list:
if i.image_type.lower() == imgtype.lower():
if fpercent > 0:
i.apply_filter(fpercent)
l.append(i)
if len(l) == 0:
return None
else:
l.sort(key = lambda x:x.image_name)
return l

if __name__ == "__main__":
n = int(input())
l1=[]
for i in range(n):
iid = int(input())
iname = input()
xcoord = int(input())
ycoord = int(input())
itype = input()
f = Image(iid,iname,xcoord,ycoord,itype)
l1.append(f)

itype = input()
fpercent = int(input())
a = Album("Wedding",l1)
c = a.calculate_coordinates(fpercent,itype)
if c == None:
print("Image Not Found.")
else:
for i in c:
print(i.image_name,i.x_coordinates,i.y_coordinates)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy