Ticker

6/recent/ticker-posts

TCS IRA PYTHON 21ST MARCH 2022 QUESTION AND SOLUTION

HELLO DORAEMONS,

IN THIS BLOGPOST ,I HAVE SHARED THE RECENTLY ASKED PYTHON QUESTION AND SOLUTION WHICH IS CERTAINLY USEFUL WHEN YOU WANT TO PRACTICE.HOPE THIS BLOG IS USEFUL TO YOU 

A Property has the following attributes: 

1. Property id, registration number 

2. Property Type , represents the type of the property 

3. Property Price , represents the price of the property



Define a class to create Property Objects Define the method in the class to initialize the attributes of the objects to be created with the values passed as argument A Property Management System has following attributes .

1. A list of Property objects

2. Tax payment record.

For each Property in the list of Properties , keeps the record of the year when the property tax was paid last. Records are maintained as "Property registration number: Year (the year in the format of yyyy when the property tax was last paid)" in the form of key:value pairs. 

Define a class to create Property Management System objects. 

Define the method in the class to initialize the attributes of the objects to be created with the values passed as argument. 

Define another methods in the Property Management System to fulfill the requirements given below. This method will take as input a value for the registration number of a Property and a value for a year (in the format yyyy). Method will do the following: 

1. Find the Property from the Property List of the Property Management System having the given registration number.

 2. If Property with the given registration number is not found, method will return o, 

3. If Property with the given registration number is found, method will check in the Tax payment record of the Property Management System if in the year passed as argument the property tax for that Property was paid last or not.

 If the property tax was last paid in the year passed as argument or in any year after that, method will return -1, Otherwise , method will calculate the Property tax for the Property. Property tax is calculated as 5% of the Property Price. 

4.  Property with the given registration number is found, and the year of the property tax last paid for that Property is before 2 years of the year passed as argument method will calculate the late fine as Rs 1000 per year for the count of years tax not paid beyond the buffer of 2 years ie the difference in years between the year passed as argument and (the year in which tax for the Property was last paid + 2).

For example, if for a Property, the year tax for the Property was last paid is 2020 and the year passed as argument is 2026, late fine will be calculated as 4* 1000 

5. In case the difference in years between the year passed as argument and the year tax for the Property was last paid is more than 10 years, method will remove the Property from the Property list of the Property Management System after calculating the tax and fine.

 Finally method will calculate the Final Tax and return. The final tax is calculated as the surmation of the calculated Property Tax (calculated as in point #3) and the late fine calculated (if any) 

Note: All numeric values should be considered as integers, Consider all Property registration numbers are unique. Instructions to write main section of the code

a. You would require to write the main section completely, hence please follow the below instructions for the same.

b. You would require to write the main program which is in line to the "sample input description section" mentioned below and to read the data in the same sequence. 

C. Create the respective objects with the given sequence of arguments to fulfill the method requirement defined in the class referring to the below instructions. 

1. Create a list of Property objects which will be provided as argument to create the Property Management System object. To create the List,

 a. Read a number (n) for the count of Property objects to be created and added to the list

 b. Create a Property object after reading the data related to it and add the object to the list of Property objects to be created. This point repeats for the number of objects (considered in the first line of input) point #c. 1.a. 

d. Read 'n' (the value read in point #c.1.a) number of key:value pairs "Property registration number: Year" for the value for Tax payment record attribute of the Property Management System object to be created.

e. Create a Property Management System object. 

f. Read values for the property registration number and the year to be passed as arguments to the second method defined in the Property Management System class.

 g. Call the second method defined in the Property Management System class with the required parameters/arguments from the main section by using the Property Management System object created and display the output as below based on the value returned by the method. . If the first method returns 0, display a message "Property not available” without the quotes

 • if the method returns -1, display a message "Tax already paid." without the quotes. Otherwise, display the final tax amount calculated and returned by the method

 h. Display the registration numbers of all the Properties available in the Property List of the Property Management System in separate liens in the same order of occurrence as per input given while creating the Property list. Refer to the sample input and output below for more clarity. You can use/refer the below given sample input and output to verify your solution using Test against Custom Input' option in Hackerrank 

Sample Input (below) description: 

a. The 1st input taken in the main section is the number of Property objects (n) to be added to the list of Property to be created. 

b. The next set of inputs are the registration number, property type and price of a Property object

This is repeated for (n) number of Property objects given in the first line of input (in point

#a).

c. The next 8 lines of inputs are the values for "Property registration number : Year"

key:value pairs for the list to be created for Tax payment record attribute of

the Property Management System object to be created.

d. The last two lines of inputs are the values for the property registration number and the

year to be passed as argument to the second method defined in the Property Management

System class.

You can consider below sample input and output to verify your implementation before

submitting in Hackerrank.

Sample Testcase 1:

Input :

4

10111

Land

6000000

10201

Land

5000000

103011

Commercial Space

500000

10411

House

400000

10411

2021

10111

2019

10201

2022

103011

2010

10111

2023

Output:

302000

10111

10201

103011

10411


Sample Testcase2:

Input :

4

10111

Land

6000000

10201

Land

5000000

103011

Commercial Space

500000

10411

House

400000

10411

2021

10111

2019

10201

2022

103011

2010

103011

2023


Output:

36000

10111

10201

10411



HOPE THIS IS HELPFUL TO YOU GUYS.IF YOU LIKE MY WORK ,CONSIDER SUBSCRIBING TO MY CHANNEL AND FOLLOW MY BLOGPOST FOR MORE UPDATES


Post a Comment

3 Comments

  1. Please check this solution is correct or not:

    class Property:
    def __init__(self,Property_Id,ProperTy_Type,Porperty_Price):
    self.Property_Id=Property_Id
    self.Property_Type=Property_Type
    self.Property_Price=Property_Price
    class Property_management_system:
    def __init__(self,property_obj,tax_payment_record):
    self.property_obj=property_obj
    self.tax_payment_record=tax_payment_record
    def calculate_tax(self,reg_no,year):
    flag=0
    for i in self.property_obj:
    if i.Property_Id==reg_no:
    flag=1
    if year==self.tax_payment_record[i.Property_Id]:
    return -1
    else:
    late_fine=0
    if year-self.tax_payment_record[i.Property_Id]<=2:
    late_fine=0
    elif year-self.tax_payment_record[i.Property_Id]<2 and year-self.tax_payment_record[i.Property_Id]<=10:
    late_fine=(year-self.tax_payment_record[i.Property_Id]-2)*1000
    else:
    late_fine=(year-self.tax_payment_record[i.Property_Id]-2)*1000
    self.property_obj.remove(i)
    total_tax=i.property_Price*0.05+late_fine
    return total_tax
    if flag==0:
    return 0

    ReplyDelete