Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F66235687
ExFree.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jun 9, 04:59
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Jun 11, 04:59 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18189919
Attached To
rCONVECTION Convection Heat Transfer Notebook
ExFree.py
View Options
import
numpy
as
np
import
ipywidgets
as
widgets
import
matplotlib.pyplot
as
plt
from
IPython.display
import
display
,
clear_output
def
EvaluateNumericalSolution
(
inputstring
,
solution
,
tolerance
):
notaNumber
=
"Result is not a number"
correct
=
"Your answer is correct!"
wrong
=
"Wrong. Please try again."
clear_output
();
try
:
result
=
float
(
inputstring
)
except
ValueError
:
print
(
notaNumber
)
return
if
np
.
abs
(
result
-
solution
)
<=
tolerance
:
print
(
correct
)
else
:
print
(
wrong
)
"""Question 3"""
def
EvalFilmTemp
():
text
=
widgets
.
Text
(
placeholder
=
'Type your answer'
)
display
(
text
)
button
=
widgets
.
Button
(
description
=
"Check answer"
)
output
=
widgets
.
Output
()
display
(
button
,
output
)
def
evaluateFilmTemp
(
b
):
with
output
:
if
text
.
value
!=
""
:
solution
=
37
resultstring
=
text
.
value
tolerance
=
0
EvaluateNumericalSolution
(
resultstring
,
solution
,
tolerance
)
else
:
clear_output
();
button
.
on_click
(
evaluateFilmTemp
)
"""Question 4.3"""
def
EvalBoundaryThickness
():
text
=
widgets
.
Text
(
placeholder
=
'Type your answer'
)
display
(
text
)
button
=
widgets
.
Button
(
description
=
"Check answer"
)
output
=
widgets
.
Output
()
display
(
button
,
output
)
def
evaluateBoundaryThickness
(
b
):
with
output
:
if
text
.
value
!=
""
:
solution
=
6.3
resultstring
=
text
.
value
tolerance
=
0.1
EvaluateNumericalSolution
(
resultstring
,
solution
,
tolerance
)
else
:
clear_output
();
button
.
on_click
(
evaluateBoundaryThickness
)
Event Timeline
Log In to Comment