Question

using python to Design a class that holds the following personal data: name, address, age, and...

using python to Design a class that holds the following personal data:

name, address, age, and phone number.

Write appropriate accessor and mutator methods.

Also, write a program that creates three instances of the class.

One instance should hold your information, and the other two should hold your friends’ or family members’ information.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Design

Coding:

class personal():
    #here is mutator method which initilize the value
    def set_data(self,p_name,p_address,p_age,p_phone):
        self.name = p_name
        self.address = p_address
        self.age = p_age
        self.phone = p_phone
    #Here is accessor method which return value
    def get_data(self):
        return "Name ::"+str(self.name)+"\nAddress::"+str(self.address)+"\nAge::"+str(self.age)+"\nPhone::"+str(self.phone)

#take an object of myinfo
print("\nThis is My Info \n")
my_info = personal()
my_info.set_data("Viral","Bhuj",18,99254)
print(my_info.get_data())


#get two object of my family
print("\nThis is First My Family member\n")
my_family_info1 = personal()
my_family_info1.set_data("poonam","anjar",28,1234)
print(my_family_info1.get_data())

print("\nThis is Second My Family member\n")
my_family_info2 = personal()
my_family_info2.set_data("Heena","Mandvi",18,99138)
print(my_family_info2.get_data())


output:

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Know the answer?
Add Answer to:
using python to Design a class that holds the following personal data: name, address, age, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In python Create a class that holds personal data: name, address, age, and phone number. Write...

    In python Create a class that holds personal data: name, address, age, and phone number. Write the necessary get (accessor) and set mutator methods. Also include a program that creates three instances of the class. This could be you and 2 friends or 2 family members.

  • PLEASE YOU PYTHON 3 TO SOLVE! THANKS! PLEASE YOU PYTHON 3 TO SOLVE! THANKS! Example 1...

    PLEASE YOU PYTHON 3 TO SOLVE! THANKS! PLEASE YOU PYTHON 3 TO SOLVE! THANKS! Example 1 Design a class named Information that holds the following personal data: .name, age, address (this attribute has a default value of “unknown"), and phone number. . All the attributes are defined as private. • Write appropriate accessor and mutator methods. • Complete the definition of the str_ method, such that it displays each Information object's data in the following format: name: "Sarah Jones” –...

  • Design a class for python named PersonData with the following member variables: lastName firstName address city...

    Design a class for python named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData , which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool . It will be...

  • Design a class named Person with fields for holding a person's name, address, and telephone number...

    Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes...

  • Using JAVA* Design a class named Person with fields for holding a person’s name, address, and...

    Using JAVA* Design a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class’s fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator...

  • Write a class named PhoneBookEntry that has fields for a person's name and phone number.The class...

    Write a class named PhoneBookEntry that has fields for a person's name and phone number.The class should have a constructor and appropriate accessor and mutator methods. Thenwrite a program that creates at least five PhoneBookEntry objects and stores them in anArrayLitt. Use a loop to display the contents of each object in the ArrayList.

  • 7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName...

    7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailinglist The customer Number variable will be used to hold a unique integer for each customer. The mailing List variable should be a bool....

  • Design a class named Employee. The class should keep the following information in

    WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite one or more constructors and the appropriate accessor and mutator functions for the class.Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:• Shift (an integer)• Hourly pay rate (a double )The workday...

  • (JAVA) Using classes and inheritance, design an online address book to keep track of the names

    (JAVA)Using classes and inheritance, design an online address book to keep track of the names, addresses, phone numbers and birthdays of family members, friends and business associates. Your program should be able to handle a maximum of 500 entries.Define the following classes: Class Address to store a street name, city, state and zip code. Class Date to store the day, month and year. Class Person to store a person's last name and first name. Class ExtPerson that extends the class...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT