PLEASE YOU PYTHON 3 TO SOLVE! THANKS!
PLEASE YOU PYTHON 3 TO SOLVE! THANKS!
Answer to above question is-
CODE:
# information class is created
class information:
# constructor method to initialize the class variables
# private variables can be made by adding __ at the starting of
variable name
def __init__(self,name,age,phoneNumber,address='uknown'):
self.__name = name #private variable
self.__age = age #private variable
self.__address = address #private variable
self.__phoneNumber = phoneNumber #private variable
#defining accessor methods
# class method to get name of the person
def get_name(self):
return self.__name
# class method to get age of the person
def get_age(self):
return self.__age
# class method to get address of the person
def get_address(self):
return self.__address
# class method to get phone Number of the person
def get_phoneNumber(self):
return self.__phoneNumber
# defining mutator methods\
# class method to change name of a person
def set_name(self,a):
self.__name =a
# class method to change age of a person
def set_age(self,a):
self.__age =a
# class method to change address of a person
def set_address(self,a):
self.__address =a
# class method to change phoneNumber of a person
def set_phoneNumber(self,a):
self.__phoneNumber =a
# class method for string representation
def __str__(self):
return 'name:"{}"-age:"{}"-address:"{}"-phone
number:"{}"'.format(self.__name,self.__age,self.__address,self.__phoneNumber)
# method to display information of person
# this method accepts object as argument
def display_info(object):
print(object)
# creating two instances of class information
n1 = information('abc',22,555555666,'us')
n2 = information('xyz',27,666555888)
# calling display_info method to show person information
display_info(n1)
display_info(n2)
# calling set_name method to change name of person
n1.set_name('pqr')
display_info(n1)
# calling set_address method to change address of a person
n2.set_address('uk')
display_info(n2)
print("phoneNumber of person {} is
{}".format(1,n1.get_phoneNumber()))
print("age of person {} is {} ".format(2,n2.get_age()))
Image of the code:
Output:
Please Comment if you have any queries related to the answer.
Please UPVOTE if answer was helpful.
Thank You.
PLEASE YOU PYTHON 3 TO SOLVE! THANKS! PLEASE YOU PYTHON 3 TO SOLVE! THANKS! Example 1...
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.
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,...
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.
*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects. PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle The class should have 8 methods as follows: For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method. For each...
python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...
can you please solve #2, 3 and 4 ? please by using Python 3 8:34 PM € Assignment Details 6202-COSC-2436-Programming Fundamentals i company TOITOWS: Ask the customer have his into G unter his own . If you SOLO u ld email. If Ask hinto anto TV unit l emname, .). Append the total Hoe to his 2. Create a class called person with name, phone and email as private attributes. Create a customer class as a sub class of person...
Lab 10C - Creating a new class This assignment assumes that you have read and understood the following documents: http://www.annedawson.net/Python3_Intro_OOP.pdf http://www.annedawson.net/Python3_Prog_OOP.pdf and that you're familiar with the following example programs: http://www.annedawson.net/python3programs.html 13-01.py, 13-02.py, 13-03.py, 13-04.py Instructions: Complete as much as you can in the time allowed. Write a Python class named "Car" that has the following data attributes (please create your own variable names for these attributes using the recommended naming conventions): - year (for the car's year of manufacture)...
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...
Write a Python class, Circle, constructed by a radius and two methods which will compute the area and the perimeter of a circle. Include the constructor and other required methods to set and get class attributes. Create instances of Circle and test all the associated methods. Write a Python class, Rectangle, constructed by length and width and a method which will compute the area of a rectangle. Include the constructor and other required methods to set and get class attributes....
please use python answering the question thanks Person Implement the Person class. Each person P has attributes name, age and job. The constructor accepts arguments for the attributes above, in the order above. Each person P has a celebrate_birthday() method, which: increments P's age; sets P's job to "Retired" if their age is now 65 or greater; returns "Happy birthday <name>!", where <name> is P's name.