Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SciProg2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
pclark3
SciProg2024
Commits
c83e7cf7
Commit
c83e7cf7
authored
1 year ago
by
cprutean
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
69c4a980
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
CodeExamples/TemperatureConverter.ipynb
+75
-0
75 additions, 0 deletions
CodeExamples/TemperatureConverter.ipynb
with
75 additions
and
0 deletions
CodeExamples/TemperatureConverter.ipynb
0 → 100644
+
75
−
0
View file @
c83e7cf7
{
"cells": [
{
"cell_type": "markdown",
"id": "74c83032",
"metadata": {},
"source": [
"# Temperature Converter"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e7d790d3",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
" Simple converter between Fahrenheit and centigrade using functions\n",
"\"\"\"\n",
"\n",
"def fahrenheit(t):\n",
" \"\"\"\n",
" Convert centigrade to fahrenheit\n",
" \"\"\"\n",
" return 1.8*t + 32\n",
"\n",
"def centegrade(t):\n",
" \"\"\"\n",
" Convert fahrenheith to centegrade\n",
" \"\"\"\n",
" return (t - 32.0)/1.8\n",
"\n",
"\n",
"def main(): # Main program\n",
"\n",
" freezing = 0.0\n",
" boiling = 100.0\n",
"\n",
" print(\"Water freezes as : \" + str(freezing) + \" C or \" + str(fahrenheit(freezing)) + \" F\")\n",
" print(\"Water boils as : \" + str(boiling) + \" C or \" + str(fahrenheit(boiling)) + \" F\")\n",
"\n",
" normalbody = 98.6\n",
" deathvalley = 134.0\n",
" \n",
" print(\"Normal body temperature is : \" + str(normalbody) + \" F or \" + str(centegrade(normalbody)) + \" C\")\n",
" print(\"Death Valley record is : \" + str(deathvalley) + \" F or \" + str(centegrade(deathvalley)) + \" C\")\n",
"\n",
"\n",
"main()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id:74c83032 tags:
# Temperature Converter
%% Cell type:code id:e7d790d3 tags:
```
python
"""
Simple converter between Fahrenheit and centigrade using functions
"""
def
fahrenheit
(
t
):
"""
Convert centigrade to fahrenheit
"""
return
1.8
*
t
+
32
def
centegrade
(
t
):
"""
Convert fahrenheith to centegrade
"""
return
(
t
-
32.0
)
/
1.8
def
main
():
# Main program
freezing
=
0.0
boiling
=
100.0
print
(
"
Water freezes as :
"
+
str
(
freezing
)
+
"
C or
"
+
str
(
fahrenheit
(
freezing
))
+
"
F
"
)
print
(
"
Water boils as :
"
+
str
(
boiling
)
+
"
C or
"
+
str
(
fahrenheit
(
boiling
))
+
"
F
"
)
normalbody
=
98.6
deathvalley
=
134.0
print
(
"
Normal body temperature is :
"
+
str
(
normalbody
)
+
"
F or
"
+
str
(
centegrade
(
normalbody
))
+
"
C
"
)
print
(
"
Death Valley record is :
"
+
str
(
deathvalley
)
+
"
F or
"
+
str
(
centegrade
(
deathvalley
))
+
"
C
"
)
main
()
```
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