我正在尝试做一个小程序来创建和管理一家银行的账户。
代码是用德语写的,我在评论里写了翻译。每次我
试图编译程序编译器说“无效语法”,但没有突出显示它。
我找不到问题,但它必须位于方法kontoEroeffnen()
我将非常感谢您的帮助。在
import sys
# makes an account with bank
class Konto :
def __init__( self , laufzeit , ID , password , zinssatz):
self.ID = ID#the ID of the account
self.laufzeit = laufzeit#runtime of the account
self.password = password
self.zinssatz = zinssatz#interest rate
self.kontostaende = list(range(laufzeit + 1)#array with the months
def authentifizierung(self): #authentication of the user
print("Geben Sie Ihre Konto ID ein")#input of the account-ID
idl = int(sys.stdin.readline().rstrip())
print("Geben Sie ihr Passwort ein")#input of the password
passwort = int(sys.stdin.readline().rstrip())
if idl == self.id :
if passwort == self.password :
return True
else:
print("Falsches Passwort")#output:wrong password
return False
else:
print("Erneut versuchen")#output:retry
return False
def einzahlen(self) :#pay into the bank
if authentifizierung() :
print("Wenn es Ihre Ersteinzahlung ist geben Sie e ein")#output:if this is your first pay, input 'e'
print("Sonst geben Sie den Monat der Laufzeit ihres Kontos ein")#output:else:input the month of the runtime of your account
eingabe = sys.stdin.readline().rstrip()
if eingabe == 'e' :
print("Geben Sie den Betrag Ihrer Einzahlung ein")#output:you have to input the sum
self.kontostaende[0] = int(sys.stdin.readline().rstrip())
#Hier muss noch der Verweis zur Startsequenz hin.... //here I want a jump to the startsequency(not important now...)
else:
index = int(eingabe)
if (index > 0 ) and (index < len(self.kontostaende)):
print("Geben Sie den Betrag Ihrer Einzahlung ein")
self.kontostaende[index] = int(sys.stdin.readline().rstrip())
# Hier muss wieder zur Startsequenz...
else :
einzahlen()
def kontosteandeVomErstenTagBerechnen(self):#calculate the account balances
for i in self.kontostaende :
self.kontostaende[i] = self.kontostaende[0]* pow((1 + self.zinssatz) , (i/self.laufzeit))
def kontostaendeVomTagDerEinzahlungBerechnen(self , index):
monate = list(range(laufzeit)) #macht eine Liste der zu veraendernden elementen //makes a list of the elements who should be changed
for i in range (index): # |
del monate[0] #-|
for i in monate :
self.kontostaende[i + index] = self.kontostaende[index] * pow((1 + self.zinssatz) , ( i / (self.laufzeit - index)))
def kontoEröffnen ():#create a new account
print("Geben Sie die gewuenschte ID Ihres Kontos ein")#input the ID of your account
ID = int(sys.stdin.readline().rstrip())
print("Geben Sie das Passwort, das Sie benutzen wollen ein, achten sie darauf es niemandem zu verraten")#input the password of your account
password = sys.stdin.readline().rstrip()
print("Geben Sie die Laufzeit des Vertrags ein")#input the runtime of your account
laufzeit = int(sys.stdin.readline().rstrip())
print("Geben Sie den Zinssatz Ihres Vertrags ein, in Dezimalschreibweise.")#input the interest rate in decimal
zinssatz = float(sys.stdin.readline().rstrip())
konto = Konto(laufzeit , ID , password , zinssatz)
return konto
#noch nicht fertig // not finished because doesn't work
def startsequenz (): #start sequency....doesn't matter for this.
print (''' Geben Sie ein ob sie ein Konto haben oder eröffnen wollen!
geben Sie, wenn Sie ein Konto haben, k ein, Sie e ein.''')
if sys.stdin.read(1) == e :
kontoEröffnen()
#nicht fertig
您的
Konto.__init__
方法中缺少右括号:最后加上括号:
^{pr2}$相关问题 更多 >
编程相关推荐