COM1001 – COMPUTER ENGINEERING DEPARTMENT (Solution)

$ 29.99
Category:

Description

Computer Programming 1
LAB6 Quiz
Assoc. Prof. Dr. Hacer YALIM KELEŞ
Please write ListClass.py file which contains the definitions of the member functions for this class. ListClass object would have an integer list, and a given name. The member functions are explained below. Test your code with the sample main function provided to you (Main.py). It must print the sample output provided to you (output.txt). You can also create and test your own main functions.
Member functions:
– printName(self): prints the name of the object
– printOdds(self): prints odd elements of the list
– printEvens(self): prints even elements of the list
– getLength(self): returns the length of the list
– changeItem(self, oldValue, newValue): oldValue and newValue are integer. If oldValue exists in the list, change its value with newValue
– addItem(self, item): item is an integer and inserts item into list. Each int in the list occurs exactly once. If item is already exists in the list, it will be ignored.
– addItems(self, items[]): “items” is an integer list and inserts this “items” into the existing list.
Since no duplicates are allowed, only non-existing values will be inserted
– removeItem(self, item): item is an integer and if item exists in the list, removes it
– removeItems(self, items[]):“items” is an integer list and removes this “items” from the existing list. Non-existing values will be ignored
– __str__(self): returns a string representation of list. Output format would be:
[element_1<space>element_2<space>………element_n]
– __lt__(self, other): returns true if sum of the elements of self list is less than other’s list elements
Testing: You are provided with an output file. You can test your program from the command line using the following commands. (>: stands for command prompt) > python Main.py > my_output.txt The outputs, which you generate using the print() function in the source codes, are redirected to my_output.txt file. You can then check if my_output.txt file is exactly the same with the provided output.txt file, using diff command from the command prompt: > diff output.txt my_output.txt
Responsible Assistant: Özge MERCANOĞLU SİNCAN (omercanoglu@ankara.edu.tr)
Submission:
1- Name your ListClass.py file as <student_id>.py; replace <student_id> using your student id number.
2- Upload your python file using the interface provided in e-kampüs course page.

Reviews

There are no reviews yet.

Be the first to review “COM1001 – COMPUTER ENGINEERING DEPARTMENT (Solution)”

Your email address will not be published. Required fields are marked *