Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sem3-ivt19-task1-1-mozgovoy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Мозговой Никита Александрович
sem3-ivt19-task1-1-mozgovoy
Commits
7fcb429f
Commit
7fcb429f
authored
Nov 12, 2020
by
Мозговой Никита Александрович
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lr6
parent
75a4d38c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
16 deletions
+10
-16
calcprint.cpython-38.pyc
__pycache__/calcprint.cpython-38.pyc
+0
-0
calcprint.py
calcprint.py
+6
-6
calculate.py
calculate.py
+4
-10
No files found.
__pycache__/calcprint.cpython-38.pyc
View file @
7fcb429f
No preview for this file type
calcprint.py
View file @
7fcb429f
...
...
@@ -21,15 +21,15 @@ def print_results(*args, action=None, result=None):
def
actionPrint
(
operands
,
action
):
lst
=
[]
for
i
in
range
(
operands
[
0
],
operands
[
-
1
]):
lst
.
append
(
f
"
{i} {action}
"
)
lst
.
append
(
f
"
{operands[-1]}
"
)
lst
.
append
(
f
"
{i} {action}
"
)
lst
.
append
(
f
"
{operands[-1]}
"
)
return
lst
arg_list
=
str
((
argsPrint
(
operands
)))
action_list
=
str
(
actionPrint
(
operands
,
action
))
st
=
f
"
| {arg_list} |
{action_list} = {result} |"
print
(
'-'
*
len
(
st
))
arg_list
=
(
" "
.
join
((
argsPrint
(
operands
)
)))
action_list
=
(
" "
.
join
(
actionPrint
(
operands
,
action
)
))
st
=
f
"
{arg_list}
{action_list} = {result} |"
print
(
'-'
*
len
(
st
))
print
(
st
)
print
(
'-'
*
len
(
st
))
...
...
calculate.py
View file @
7fcb429f
...
...
@@ -51,12 +51,6 @@ def calculate(*args, **kwargs):
return
round
(
result_division
,
precision
)
print
(
calculate
(
*
list
(
range
(
1
,
10
)),
"+"
,
**
PARAMS
),
'
\n
'
)
# 1 + 2 + 3 + .. + 9
print
(
calculate
(
*
list
(
range
(
1
,
10
)),
"-"
,
**
PARAMS
),
'
\n
'
)
print
(
calculate
(
*
list
(
range
(
1
,
5
)),
"/"
,
**
PARAMS
),
'
\n
'
)
print
(
calculate
(
*
[
1.0001
,
2.2345
],
"*"
,
**
PARAMS
),
'
\n
'
)
# 2.23472345
def
test_packed_calc_sum
():
inp1
,
action
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
],
"+"
assert
calculate
(
*
inp1
,
action
,
...
...
@@ -66,8 +60,8 @@ def test_packed_calc_sum():
if
__name__
==
"__main__"
:
# print(calculate(*list(range(1, 10)), "+", **PARAMS), '\n')
# 1 + 2 + 3 + .. + 9
# print(calculate(*list(range(1, 10)), "-", **PARAMS), '\n')
# print(calculate(*list(range(1, 5)), "/", **PARAMS), '\n')
# print(calculate(*[1.0001, 2.2345], "*", **PARAMS), '\n') # 2.23472345
assert
calculate
(
*
list
(
range
(
1
,
10
)),
"+"
,
**
PARAMS
)
==
45.0
# 1 + 2 + 3 + .. + 9
assert
calculate
(
*
list
(
range
(
1
,
10
)),
"-"
,
**
PARAMS
)
==
-
45
assert
calculate
(
*
list
(
range
(
1
,
5
)),
"/"
,
**
PARAMS
)
==
0.04167
assert
calculate
(
*
[
1.0001
,
2.2345
],
"*"
,
**
PARAMS
)
==
2.23472
print_results
(
*
list
(
range
(
1
,
10
)),
action
=
"+"
,
result
=
calculate
(
*
list
(
range
(
1
,
10
)),
"+"
,
**
PARAMS
))
\ 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