Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi guys, So I have a list of objects, each which belong to a particular subclass

ID: 3661271 • Letter: H

Question

Hi guys, So I have a list of objects, each which belong to a particular subclass. I am trying to calculate a running standard deviation as follows: Resistance = [] i = 0 for row in Reader: if len(row) == 0 or row[0] == '': i+=1 continue else: Resistance.append(tuple((float(x) if x.strip() else '0.0') for x in row[4:])) i+=1 b1 = Resistance[2] b2 = Resistance[3] b3 = Resistance[4] b4 = Resistance[5] b5 = Resistance[6] b6 = Resistance[7] BR1 = [] BR1.append(b1) BR1.append(b2) BR1.append(b3) BR1.append(b4) BR1.append(b5) BR1.append(b6) numsB = array(BR1) print numsB.std(axis=0) however this returns the error: print numsB.std(axis=0) TypeError: cannot perform reduce with flexible type I have been trying various methods to get it to work and I can't seem to figure out what's wrong. Additionally, you may have noticed I inserted a '0.0' above wherever the excel spreadsheet contains a blank column, however I cannot keep it this way because I am calculating a standard deviation. Could I make it so that when Python calculates the StDev, wherever it encounters a '' it treats it as nothing, rather than zero? Thank you so much.

Explanation / Answer

You can access the "protected" variables. And one advantage is that you can save some coding time by using the inherited methods, if there are common methods between them. For example, you got a Vehicle class, Car class, Holden class. Holden obviously is a subclass of Car, Car is a subclass of Vehicle. For Car you can drive them (you could also drive a boat, but the driving method will be different), and pretty much you don't want to repeat all the driving methods in all the different classes like Holden, Ford etc. So when you're writing a program, when John buy a Toyota, you don't need to create a whole new class and rewrite all those common methods for Toyota. reference: whrl.pl/RcNe5j posted 2011-Jun-17, 8pm AEST edited 2011-Jun-17, 8pm AEST User #142916 3081 posts Argh, Hmm.. Whirlpool Forums Addict check out polymorphism too. reference: whrl.pl/RcNe5Z posted 2011-Jun-17, 8pm AEST User #368413 1064 posts wirelessgizmo Whirlpool Enthusiast Read up on Object Oriented Programming. Polymorphism is a *huge* thing when it comes to OOD, without it you won't get far! reference: whrl.pl/RcNflT posted 2011-Jun-17, 9pm AEST User #111194 2658 posts ~sapi Whirlpool Forums Addict Put simply, it's there to save you a lot of time. For example, imagine you're coding a way to represent people at a university. Everyone at the university is clearly a Person: they share some common characteristics, such as name and age. However, we then can break them down into two sub-groups: staff and students. Subclasses mean that you don't have to code the information that is common to them in both classes. This becomes important when you take things further. For example, sub-groups of staff include academic staff and general staff. Sub-groups of academic staff might include full-time lecturers, casual tutors, and professors. Professors can be further broken down into tenured professors and associate professors, for example. Each level there has something in common. For example, all staff have a salary; all academic staff belong to an organisational unit (faculty); and all professors belong to a specific school and have defined research interests. If you didn't use subclasses to represent that, you'd need to rewrite very common information, such as name, age, and salary, dozens of times.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote