Given me an error syntax while coding object oriented programing,OOP LAB quiz 3,please where im i missing it?

homework
python

#1

,,,
class BankAccount:

def_init_(self,balance = 0):

self.balance = "balance"

def deposit(self,amount):

self.balance += amount

def withdraw(self,amount):

self.balance -= amount

if amount>self.balance:

return invalid transaction

class MinimumBankAccount(BankAccount)
,,,


#2

"How do I go about finding it" is a much more engaging question than "fix my problem", even more so when if it's homework which you're meant to work through yourself.

Use backticks

```

for marking code as pre-formatted text, or start each line with an extra 4 spaces (easily done in a code editor)


#3

Thank you for your swift response,but still confused,though im suppose to do it myself but the way the curriculum is its a bit confusing,what i inderstand about indenting as in the curriculum, is given four spaces before you begin writing your code. For instance, --- To create a class shoe. I will live out four spaces before the Class statement, I want to know if im right and also get some advise on how to improove.
Thank you


#5

Without a clear specific question there's nothing for me to reply with.

If you find indentation to be confusing, google for tutorials on Python indentation. Play around with very simple code (2-5 lines) where you just test what effect indentation has.

Other people will certainly have wondered about this so there will be plenty of articles that explain it.


#6

I indented the code in this format below,but still given me syntax error after running it

class BankAccount:
def_init_(self,balance = 0):
self.balance = balance
def deposit(self,amount):
self.balance += amount
def withdraw(self,amount):
self.balance -= amount
if amount>self.balance:
return invalid transaction
class MinimumBankAccount(BankAccount)


#7

You've looked at your post, right?

And if you got an error, read the error. If you can't make out what it means, try again with less lines until you have something that works the way you want.


#8

class BankAccount:
def init(self, initial_amount):
self.balance = initial_amount
def deposit(self, amount):
self.balance += amount
def withdraw(self, amount):
if self.balance>amount:
self.balance -= amount
else:
print('invalid transaction')

a1 = BankAccount (90)
a1.deposit(180)
a1.withdraw(140)
class MinimumBalanceAccount(BankAccount):
def init(self):
BankAccount.init(self)

I just worked on the code again and came up with this above,but the astonishing part of it is that i tried submitting it so that i can move on to quiz 4, but its not letting me.
Please how do i move on to the next quiz,time is not on my side. thank you


#9

I can't help with an answer, I can't even tell what your question is, but if you format your code then things will be clearer for any people who might be interested in helping.

How to post code in this forum.

I have absolutely no information about these quizzes that you are referring to.


#10

class BankAccount:
    def __init__(self, initial_amount):
        self.balance = initial_amount
    def deposit(self, amount):
        self.balance += amount
    def withdraw(self, amount):
        if self.balance>amount:
            self.balance  -=  amount
        else:
          print('invalid transaction')

a1 = BankAccount (0.0)
a1.deposit(90)
a1.withdraw(50)
class MinimumBalanceAccount(BankAccount):
    def __init__(self):
        BankAccount.__init__(self)

#11

After formatting and running the code, i got this error message below.

{"finished": true, "success": [{"fullName": "test_balance", "passedSpecNumber": 1}, {"fullName": "test_deposit", "passedSpecNumber": 2}, {"fullName": "test_sub_class", "passedSpecNumber": 3}, {"fullName": "test_withdraw", "passedSpecNumber": 4}], "passed": false, "started": true, "failures": [{"failedSpecNumber": 1, "fullName": "test_invalid_operation", "failedExpectations": [{"message": "Failure in line 23, in test_invalid_operation\n self.assertEqual(self.my_account.withdraw(1000), \"invalid transaction\", msg='Invalid transaction')\nAssertionError: Invalid transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0, "time": "0.000074"}}
invalid transaction

My question is "where in the code do i have an invalid transaction and where have i missed it"

Thank you.


#12

class BankAccount:
    def __init__(self, initial_amount):
        self.balance = initial_amount
    def deposit(self, amount):
        self.balance += amount
    def withdraw(self, amount):
        if self.balance>amount:
            self.balance  -=  amount
        else:
          print('invalid transaction')

a1 = BankAccount (0.0)
a1.deposit(90)
a1.withdraw(50)
class MinimumBalanceAccount(BankAccount):
    def __init__(self):
        BankAccount.__init__(self)

Just came up with this after formatting the code but still having invalid transaction error,please where am i wrong?


#13

What does the question ask you to achieve? Maybe that'll guide the person trying to answer.


#14

Thank you so much, i allready realized my misstake, i used print instead of return


#15

Funny, just right now I made a similar mistake on codecademy challenge I was tackling and I just solved it. Well done.
How far have U gone with the Homestudy Test?


#16

Really, thats funny indeed,actually i got the email just last week,due to this i havent gone too far, im still tackling with quiz 4, the lab aspect. and you, how far have you gone?
Can you help out with it im stuck.here is my code below.

def manipulate_data(kind, data):
    if kind == 'list':
        return list.reverse 
    elif kind == 'set': 
        set.add("ANDELA"+"TIA"+"AFRICA") 
        return set 
    elif kind == 'dictionary':
        return data.keys()
        raise ValueError("invalid kind %r, expected 'list', 'set' or 'dictionary'" % (kind,))


#call the function with an ARGUMENT
manipulate_data("list", [25,16,9,4,1])
manipulate_data("set", {"ANDELA", "TIA", "AFRICA"})
manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45})

BUT IM GETTING THIS ERROR BELOW
Traceback (most recent call last):
File "prog.py", line 14, in
File "prog.py", line 5, in manipulate_data
TypeError: descriptor 'add' requires a 'set' object but received a 'str'

My question is "descriptor 'add' requires a 'set' object but received a 'str". what does that mean?


#17

I haven't started the labs, but maybe I can help.
From my point of view, the problem is with Ur representation of data types. Are "set" and "list" strings? Also, does it not matter that U use single quotes(' '), double quotes (" ") and no quotes alternatively for them at different points?


#18

Please i dont seem to get that, can you expansiate a little


#19

Have U solved it yet? If not, send me Ur number and let me add U to a Whatsapp group where they provide assistance on stuffs like this.


#20

Thank you ,this is my number. 08064467913


#21

Let me have your number as well