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
1c8a47a4
Commit
1c8a47a4
authored
1 year ago
by
cprutean
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
16429e25
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CodeExamples/FloatFormat.ipynb
+56
-0
56 additions, 0 deletions
CodeExamples/FloatFormat.ipynb
with
56 additions
and
0 deletions
CodeExamples/FloatFormat.ipynb
0 → 100644
+
56
−
0
View file @
1c8a47a4
{
"cells": [
{
"cell_type": "markdown",
"id": "1a8d21b9",
"metadata": {},
"source": [
"# Float Format"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51684c90",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
" Example to format floats using .format() method\n",
"\"\"\"\n",
"import math\n",
"import random\n",
"\n",
"s = \"Value of pi is : {0:12.8f}\".format(math.pi)\n",
"print(s)\n",
"\n",
"x = random.random()\n",
"y = random.random()\n",
"z = random.random()\n",
"\n",
"print(\"The three random numbers are :\\n x = {0:6.4f} y = {1:6.4f} z = {2:6.4f}\".format(x,y,z)) "
]
}
],
"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:1a8d21b9 tags:
# Float Format
%% Cell type:code id:51684c90 tags:
```
python
"""
Example to format floats using .format() method
"""
import
math
import
random
s
=
"
Value of pi is : {0:12.8f}
"
.
format
(
math
.
pi
)
print
(
s
)
x
=
random
.
random
()
y
=
random
.
random
()
z
=
random
.
random
()
print
(
"
The three random numbers are :
\n
x = {0:6.4f} y = {1:6.4f} z = {2:6.4f}
"
.
format
(
x
,
y
,
z
))
```
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