0% found this document useful (0 votes)
35 views

Assignment 4 - Modules & OOP

This document provides instructions for an assignment on Python modules and object-oriented programming (OOP). Students are asked to complete 5 questions involving defining classes and methods. The questions have students practice concepts like defining classes, methods, calculations within methods, and adding comments. Students are instructed to submit their assignment as a .pdf file with their name and student ID in the file name. Plagiarism is strictly prohibited. Late submissions will be penalized. The 5 questions have students define a Student class with attributes like name and GPA, then create objects and methods to display attributes and update GPA based on study time. They are also asked to plot various mathematical functions using matplotlib.

Uploaded by

Aneeqaa Abrar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Assignment 4 - Modules & OOP

This document provides instructions for an assignment on Python modules and object-oriented programming (OOP). Students are asked to complete 5 questions involving defining classes and methods. The questions have students practice concepts like defining classes, methods, calculations within methods, and adding comments. Students are instructed to submit their assignment as a .pdf file with their name and student ID in the file name. Plagiarism is strictly prohibited. Late submissions will be penalized. The 5 questions have students define a Student class with attributes like name and GPA, then create objects and methods to display attributes and update GPA based on study time. They are also asked to plot various mathematical functions using matplotlib.

Uploaded by

Aneeqaa Abrar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

INSTITUTE OF SPACE TECHNOLOGY

DEPARTMENT OF SPACE SCIENCE


RG731- ADVANCED PROGRAMING AND CUSTOMIZING GIS
Batch & Section:
Student Registration No.:
Student Full Name:
 Cheating by all means is prohibited and any such attempt may lead to serious consequences.

Assignment 4 – Modules & OOP


This assignment is designed to help you develop your analysis skills by providing you with the
opportunity to practice breaking small problems down into sequences of steps. The assignment consists
of 5 compulsory questions.

The questions are designed to help you become familiar with Python’s modules and OOP. To complete
each question, you must do a dry run. You should expect to use some or all of the following Python
features:

 Define a class for later use


 Defining methods
 Perform a complex calculation within a method
 Add enough comments

After you have completed the assignment, you need to submit the file in a .pdf format. The file you
submit should have an appropriate file type. The file should include your name and your registration
number e.g., abc_123456789_assignment4.pdf -- would be an appropriate filename for a student with
name abc and 123456789 that was submitting a file for homework assignment 4.

We expect students to not look at implementations online and do the assignment themselves.
Plagiarism will be dealt with strictly.

Late submissions will be penalised.

Spring 2021 Page 1 of 2


Questions [15 Marks]
1. Define a student class. A student has the following attributes: firstname, lastname, gender which
can be male or female, status which can be equal to freshman, sophomore, junior, and senior and
gpa.
Then define the following methods for the student class.
 The show_myself method will simply print all the attribute variables when called upon the
object. This method has no input arguments.
 The study_time method will increment the gpa of the student according to the following
formula: ` gpa = gpa + log(study_time) `. The only input argument of this method is the
variable study_time. In addition, make sure that the gpa variable never exceeds 4.0 even if
the student studies for a very long time.
Now define 5 student objects and store the objects in a list called student_list. The five students are:
Mike Barnes, Jim Nickerson, Jack Indabox, Jane Miller and Mary Scott. Mike is a freshman, Jim a
sophomore, Jack a junior, Jane and Mary are seniors. Their respective GPAs are: 4, 3, 2.5, 3.6 and
2.7. Make sure you assign the gender when you instantiate the objects.
Then call the show_myself method on all of them. We suggest you use a loop for making the objects
and a separate loop for showing the objects.
Use your objects from above and let each one of the 5 students study for 60, 100, 40, 300, 1000
minutes, respectively. So the first student studies 60 minutes, the second studies 100 minutes, etc.
After that call the show_myself methods on all 5 again and check whether their new gpa reflects
how much they studied.

2. Plot the following function: y=ln(x)

3. Plot a straight horizontal line at y value of 5 in a range of x between -3 and 5.

4. Plot a vertical line at x position 3 that goes from y = 0 to y = 9.

5. Write a code to plot both sine and cosine curves in the same plot with proper legend.

Spring 2021 Page 2 of 2

You might also like