Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uni_prac
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Санников Тимофей
uni_prac
Commits
6e47da0c
Commit
6e47da0c
authored
1 year ago
by
Санников Тимофей
Browse files
Options
Downloads
Patches
Plain Diff
added classwork
parent
398f7d36
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
20231031/0/prog1.py
+36
-0
36 additions, 0 deletions
20231031/0/prog1.py
with
36 additions
and
0 deletions
20231031/0/prog1.py
0 → 100644
+
36
−
0
View file @
6e47da0c
class
Rectangle
:
rectcnt
=
0
def
__init__
(
self
,
x1
,
y1
,
x2
,
y2
):
self
.
x1
,
self
.
x2
,
self
.
y1
,
self
.
y2
=
x1
,
x2
,
y1
,
y2
self
.
__class__
.
rectcnt
+=
1
k
=
int
(
Rectangle
.
rectcnt
)
setattr
(
self
,
f
'
rect_
{
k
}
'
,
k
)
def
__str__
(
self
):
return
f
'
{
self
.
__class__
.
rectcnt
}
:(
{
self
.
x1
}
,
{
self
.
y1
}
)(
{
self
.
x1
}
,
{
self
.
y2
}
)(
{
self
.
x2
}
,
{
self
.
y1
}
)(
{
self
.
x2
}
,
{
self
.
y2
}
)
'
def
__lt__
(
self
,
item
):
return
abs
(
self
)
<
abs
(
item
)
def
__eq__
(
self
,
item
):
return
abs
(
self
)
==
abs
(
item
)
def
__abs__
(
self
):
return
(
self
.
x2
-
self
.
x1
)
*
(
self
.
y2
-
self
.
y1
)
def
__mul__
(
self
,
item
):
return
Rectangle
(
self
.
x1
*
item
,
self
.
y1
*
item
,
self
.
x2
*
item
,
self
.
y2
*
item
)
def
__rmul__
(
self
,
item
):
return
Rectangle
(
self
.
x1
*
item
,
self
.
y1
*
item
,
self
.
x2
*
item
,
self
.
y2
*
item
)
def
__getitem__
(
self
,
item
):
if
item
==
0
:
return
f
'
(
{
self
.
x1
}
,
{
self
.
y1
}
)
'
if
item
==
1
:
return
f
'
(
{
self
.
x1
}
,
{
self
.
y2
}
)
'
if
item
==
2
:
return
f
'
(
{
self
.
x2
}
,
{
self
.
y1
}
)
'
if
item
==
3
:
return
f
'
(
{
self
.
x2
}
,
{
self
.
y2
}
)
'
a
,
b
=
Rectangle
(
0
,
0
,
4
,
4
,),
Rectangle
(
1
,
2
,
3
,
4
)
print
(
a
,
b
)
print
(
a
.
rectcnt
,
a
.
rect_1
)
print
(
abs
(
a
),
abs
(
b
))
print
(
b
<
a
,
a
==
b
)
print
(
b
*
5
,
a
*
2
)
print
(
a
[
1
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment