Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ansire
/
IAX0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3f078ca9
authored
Sep 23, 2017
by
ansire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
outputi vormistus
parent
61598d93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
KodutooI/kodutoo.py
KodutooI/kodutoo.py
View file @
3f078ca9
from
math
import
sqrt
algv22rtus
=
float
(
input
(
"Sisestage f(n) algv22rtus: "
))
samm
=
float
(
input
(
"Sisestage sammu suurus: "
)
)
ylempiir
=
float
(
input
(
"Sisestage f(n) ylempiir
: "
))
#fn=(1/x**2)+(x/sqrt(4+x
))
print
(
'''Programm lahendab funktsiooni y=(1/x**2)+(x/sqrt(4+x)) viieteistkymnes punktis
Funktsiooni reaalarvuline m22ramispiirkond on (-4;0)(0;inf] '''
)
algv22rtus
=
float
(
input
(
"Sisestage fn(x) algv22rtus A
: "
))
samm
=
float
(
input
(
"Sisestage fn(x) argumendi samm H: "
))
ylempiir
=
float
(
input
(
"Sisestage fn(x) ylempiir YM: "
))
i
=
0
fnV22rtused
=
[]
xV22rtused
=
[]
fnV22rtus
=
0
while
i
<
15
:
xV22rtused
.
append
(
algv22rtus
)
xV22rtused
.
append
(
round
(
algv22rtus
,
4
)
)
try
:
fnV22rtus
=
(
1
/
algv22rtus
**
2
)
+
(
algv22rtus
/
sqrt
(
4
+
algv22rtus
))
except
ZeroDivisionError
:
fnV22rtused
.
append
(
"
Imaginaararv
"
)
fnV22rtused
.
append
(
"
-
"
)
i
+=
1
algv22rtus
+=
samm
continue
except
ValueError
:
fnV22rtused
.
append
(
"I
maginaararv
"
)
fnV22rtused
.
append
(
"I"
)
i
+=
1
algv22rtus
+=
samm
continue
algv22rtus
+=
samm
print
(
fnV22rtus
,
algv22rtus
-
1
)
if
fnV22rtus
<
ylempiir
:
fnV22rtused
.
append
(
round
(
fnV22rtus
,
2
))
fnV22rtused
.
append
(
round
(
fnV22rtus
,
4
))
i
+=
1
else
:
fnV22rtused
.
append
(
"
V22rtus puudub
"
)
fnV22rtused
.
append
(
"
-
"
)
i
+=
1
print
(
'"I" - imaginaararvuline lahendus, "-" - fn(x) v22rtus puudub v6i y>YM'
)
print
(
'{0:^2s}{1:^10s}{2:^10s}'
.
format
(
'nr.'
,
'X'
,
'Y'
))
for
i
in
range
(
len
(
xV22rtused
)):
try
:
print
(
'{0:>2d}{1:>10.4f}{2:>10.4f}'
.
format
(
i
+
1
,
xV22rtused
[
i
],
fnV22rtused
[
i
]))
except
ValueError
:
print
(
'{0:>2d}{1:>10.4f}{2:^10s}'
.
format
(
i
+
1
,
xV22rtused
[
i
],
fnV22rtused
[
i
]))
print
(
xV22rtused
)
print
(
fnV22rtused
)
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