Secret Project 331-Helsinki Exam Python Advanced Course
Secret Project 331-Helsinki Exam Python Advanced Course
Exercise 1
Complete this in exercise template exercise1.py
a)
b)
print(q1)
Sample output:
Exercise 2
Complete this in exercise template exercise2.py
class BankAccount:
def __init__(self, customer: str, account_number: str,
saldo: float, credit: float):
self.customer = customer
self.account_number = account_number
self.saldo = saldo
self.credit = credit
def __str__(self):
return (f"BankAccount(customer={self.customer}, " +
f"account_number={self.account_number}, " +
f"saldo={self.saldo}, credit={self.credit})")
Implementation for the operator ==: two accounts are equal, if account numbers are
the same
Implementation for the operator >: account a is greater than account b, if the total
saldo and credit of account a is greater than the total saldo and credit of account b
Implementation for the operator +: method returns new BankAccount-object,
whose customer and account number are retrieved from the current (self) object.
The saldo of new account is sum of the saldo of both accounts. Credit is calculated in
the same way.
Sample output:
True
False
True
BankAccount(customer=Peter Python, account_number=12345,
saldo=300.0, credit=800.0)
Exercise 3
Complete this in exercise template exercise3.py
The function must not return the same item twice. When requesting the next item from
the generator, the function must raise the StopIteration exception, if the list given as
a parameter is empty or all items in the list have been returned once.
Sample output:
Bear
Fox
Chicken
Gorilla
Project Github
ABOUT MOOC CENTER
The MOOC Center creates custom online courses for the University of Helsinki. It’s behind the highly popular
courses that have been available in mooc.fi from 2012. The platform for the courses has been developed in-
house by teams comprising both university employees and students.
RESOURCES
Privacy