[Solved] CS 115 Introduction to Programming in Python Lab Guide 07A

$25

File Name: CS_115__Introduction_to_Programming_in_Python_Lab_Guide_07A.zip
File Size: 555.78 KB

SKU: [Solved] CS 115 – Introduction to Programming in Python Lab Guide 07A Category: Tag:
5/5 - (1 vote)

Lab Objectives: Classes

Instructions: Upload your solutions as a single .zip file to the Lab07 assignment on Moodle before the end of your lab session. Use the following naming convention:

SS_Lab07_Surname_FirstName.zip where SS is the section number 01, 02, 03, etc.

  1. Write a class called Person (py) that represents a typical Person object.
    1. The class will store the following attributes:
      • Name
      • Age
      • Gender
      • Location
    2. Your class should have an init() method that takes the values of all four attributes as parameters.
    3. Your class should have the following methods:
      • Name: returns the value of the attribute
      • Age: returns the value of the attribute
      • Gender: returns the value of the attribute
      • Location: returns the value of the attribute + updates value of the attribute
  1. You should also write IncreaseAge() method for increasing the persons age.
  2. In addition to the accessor/mutator methods, your class should define a __repr__ method that returns the string information about the Person in the following format, where

gulsah is the name, 21 is the age, and female is the gender and ankara location):

Name : gulsah Age : 21

Gender : female

Location: ankara

  1. Create a script that does the following:
    1. Define method getByLocation(): takes a list of Persons as a parameter and returns the list of Persons who have the location passed as a parameter.
    2. Define method getByGender(): takes a list of Persons as a parameter returns the list of Persons who have the gender passed as a parameter.
    3. Read data from the file input.txt and creates a list of People using data from the file.
    4. Using the list and the functions defined in part a and b, print all the females in Ankara.

Sample Run:

Printing Females in Ankara

Name: gizem

Age: 21

Gender: female

Location: ankara

Name: gulsah

Age: 21

Gender: female

Location: ankara Output will appear as follows:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS 115 Introduction to Programming in Python Lab Guide 07A
$25