using python 3: i always grade my answer.. Lab 8-Two Designs for a class Run thi
ID: 3600804 • Letter: U
Question
using python 3: i always grade my answer..
Lab 8-Two Designs for a class Run this example FIRST: Classes - Two Versions class Student definit(self, tmpID, tmpName, tmMajor, tmpGPA) self. __listStulnfo = [tmplD, tmpName, tmMajor, tmpGPA] def _str _(self ): return strself. __listStulnfo[O]) + " " + self.__istStulnfo[1] + " " + self.__listStulnfo[2] + " "+ strtself .__listStulnfo[3]) + " " def getID(self ): return self. listStulnfo[O ] def setIDself, newlD) self. listStulnfo[O ] = newID class Student definit (self, tmpID, tmpName, tmMajor, tmpGPA) self. _ID = tmplD self._name = tmpName self.major = tmMajor self. GPA = tmpGPA def _str _(self ): return strself. _ ID) + " " +self.__name + " " + ] self._major + " " + strtself ._GPA) + " " def getID(self : return self.LID def setID(self, newID). self. _ID = newID Test each class with the SAME program, but a different IMPORT statement from modStudent import * s1 = Student 111" Jones", "Chemistry",3.4); print(s1) id = $1.getID( ); print "ID: ", id) s1.setID(222); print "After changing id to 222: ", s1 ) from modStudentV2 import * sl = Student111,"Jones", "Chemistry",3.4 ); prints1) id = $1.getID( ); print "ID: ", id) s1. setID(222); print "After changing id to 222: ", s1)Explanation / Answer
""" File Name : account_list.py Author : Date : 10/25/2017 Description : """ class Account(object): def __init__(self, tmpAcctNum, tmpBankName, tmpAcctType, tmpBalance): """ :param tmpAcctNum: :param tmpBankName: :param tmpAcctType: :param tmpBalance: """ self.__data = [tmpAcctNum, tmpBankName, tmpAcctType, tmpBalance] def __str__(self) -> str: return "Account#: " + str(self.__data[0]) + " Bank :" + self.__data[1] + " AccountType :" + self.__data[ 2] + " Balance :$" + str(self.__data[3]) def computeInterest(self): interest_rate = 8.5 interest = self.__data[3] * 8.5 / 100 self.__data[3] = self.__data[3] + interest def getAccountNum(self): return self.__data[0] def setAccountNumber(self, accNumber): self.__data[0] = accNumber def getBank(self): return self.__data[1] def setBank(self, bank): self.__data[1] = bank def getAccountType(self): return self.__data[2] def setAccountType(self, accType): self.__data[0] = accType def getBalance(self): return self.__data[3] def setBalance(self, balance): self.__data[0] = balance
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.