1.
def sortAlphabeticalOrder(studentlist):
return studentlist.sort(key=get_first_name) #sort has
key parameter where we can pass a function which applies on the
calling objcet itself according to which we can sort
2.
def
findStudentByName(studentList):
#passing studentList as parameter inputing the name and searching
through entire list.
studentName = input("Enter name of the student you
want to search for: ")
for student in studentList:
if(student.get_first_name()+"
"+student.get_last_name()==studentName):
print(student)
return
print("Couldn't find any student with the provided
name!.")
3.
def
topicObject(topicList):
#passing topicList and inputing courseid with we we search through
entire list.
topicCode = input("Enter course Code you wanted to
search for: ")
for topic in topicList:
if topic.__topic_code ==
topicCode:
print(subject)
return
print("Couldn't find any topic with the course code
provided!.")
#in some function name of yours there are spaces which is not acceptable. I have use _ instead of spaces here.
#Please leaving your rating. It makes me motivated. Also don't hesitate to ask any doubts in the comments section below.
Use of search structures! how can i make this program in python? Learning Objectives: You should...
How do I make my code print out the text in the ServiceNotifier class? Python Code: class ServiceNotifier: #Subject responsible for notifying registered observer objects Observer = [Email, SMS, Phone] def attach(self): #add new observer Observer.append(insertnewobserverhere) def dettach(self): #remove an observer Observer.pop(insertnewobserverhere) def servicenotifier(self): for observers in Observer: print("Due to the forecast for tomorrow, all university and campus operations will be closed.") ...
PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList: def __init__(self): self.__head = None self.__tail = None self.__size = 0 def insert(self, i, data): if self.isEmpty(): self.__head = listNode(data) self.__tail = self.__head elif i <= 0: self.__head = listNode(data, self.__head) elif i >= self.__size: self.__tail.setNext(listNode(data)) self.__tail = self.__tail.getNext() else: current = self.__getIthNode(i - 1) current.setNext(listNode(data,...
PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...
Must be in Python 3 exercise_2.py # Define the Student class class Student(): # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...
class students: count=0 def __init__(self, name): self.name = name self.scores = [] students.count = students.count + 1 def enterScore(self): for i in range(4): m = int(input("Enter the marks of %s in %d subject: "%(self.name, i+1))) self.scores.append(m) def average(self): avg=sum(self.scores)/len(self.scores) return avg def highestScore(self): return max(self.scores) def display(self): print (self.name, "got ", self.scores) print("Average score is ",average(self)) print("Highest Score among these courses is",higestScore(self)) name = input("Enter the name of Student:") s = students(name) s.enterScore() s.average() s.highestScore() s.display()So I need to print two things, first one is to compute the average score of these courses and second one is to print out the course name with the highest score among these courses. Moreover I need to import matplotlib.pyplot as plt to show the score figure. I barely could pull the code this...
In Python !!! In this exercise you will continue to work with Classes and will build on the Book class in Lab 13.10; you should copy the code you created there as you will need to extend it in this exercise. You will extend the Book class to accommodate the case where there may be multiple authors for a book. The attribute author should become a list. The constructor will still take a parameter that is a string for author,...
PYTHON QUESTION... Building a Binary Tree with extended Binary Search Tree and AVL tree. Create a class called MyTree with the methods __init__(x), getLeft(), getRight(), getData(), insert(x) and getHeight(). Each child should itself be a MyTree object. The height of a leaf node should be zero. The insert(x) method should return the node that occupies the original node's position in the tree. Create a class called MyBST that extends MyTree. Override the method insert(x) to meet the definitions of a...