Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SpartanBots
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roshan Rabinarayan
SpartanBots
Commits
e5951e5e
Commit
e5951e5e
authored
Sep 19, 2020
by
Samarth Joshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug Fixes q6
parent
508dd088
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
q6/q6.py
q6/q6.py
+21
-13
No files found.
q6/q6.py
View file @
e5951e5e
from
functools
import
total_ordering
@
total_ordering
class
BlackMoneyHolder
:
def
__init__
(
self
,
name
,
accounts_info
):
self
.
name
=
name
...
...
@@ -13,7 +14,7 @@ class BlackMoneyHolder:
return
len
(
self
.
accounts_info
)
def
__getitem__
(
self
,
item
):
return
self
.
accounts_info
[
item
]
return
list
(
self
.
accounts_info
.
items
())
[
item
]
def
__eq__
(
self
,
other
):
return
self
.
total_black_money
()
==
other
.
total_black_money
()
...
...
@@ -21,22 +22,18 @@ class BlackMoneyHolder:
def
__lt__
(
self
,
other
):
return
self
.
total_black_money
()
<
other
.
total_black_money
()
def
__gt__
(
self
,
other
):
return
self
.
total_black_money
()
>
other
.
total_black_money
()
def
__str__
(
self
):
for
i
in
self
.
accounts_info
:
print
(
"
%
s:
%
s"
%
(
i
,
self
.
accounts_info
[
i
]))
return
''
return
"
\n
"
.
join
([
key
+
": "
+
str
(
value
)
for
key
,
value
in
accounts_info
.
items
()])
def
update_amount
(
self
,
name
,
amount
):
self
.
accounts_info
[
name
]
=
amount
def
total_black_money
(
self
):
total_money
=
0
for
i
in
accounts_info
:
total_money
+=
self
.
accounts_info
.
get
(
i
)
for
i
in
self
.
accounts_info
:
total_money
=
total_money
+
self
.
accounts_info
.
get
(
i
)
return
total_money
name
=
"Gonia Sandhi"
accounts_info
=
{
"Random Bank"
:
1000
,
...
...
@@ -44,16 +41,27 @@ accounts_info={
"Lena Bank"
:
2000
,
}
b1
=
BlackMoneyHolder
(
name
,
accounts_info
)
print
(
b1
)
print
(
b1
.
total_black_money
())
b1
.
update_amount
(
"Blood Bank"
,
2500
)
print
(
b1
.
total_black_money
())
name
=
"Champak Lal"
accounts_info
=
{
for
account
in
b1
:
print
(
account
)
name2
=
"Champak Lal"
accounts_info2
=
{
"Random Bank"
:
2000
,
"Dena Bank"
:
7000
,
"Lena Bank"
:
9000
,
}
b2
=
BlackMoneyHolder
(
name
,
accounts_info
)
b2
=
BlackMoneyHolder
(
name2
,
accounts_info2
)
print
(
b2
)
print
(
b2
.
total_black_money
())
print
(
b1
==
b2
,
b1
>
b2
,
b1
<
b2
)
print
(
b1
)
print
(
b1
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment