FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/simple_datatypes/str_fstrings.py at main · thomasWeise/programmingWithPythonCode · GitHub
thomasWeise
programmingWithPythonCode
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programmingWithPythonCode
/
simple_datatypes
/
str_fstrings.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (19 loc) · 921 Bytes
Breadcrumbs
programmingWithPythonCode
/
simple_datatypes
/
str_fstrings.py
Copy path
File metadata and controls
26 lines (19 loc) · 921 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
f"
{
12345678901234
}
is a really big integer."
f"12345678901234 with thousand separator ',' is
{
12345678901234
:,
}
."
f"
{
12345678901234
}
in hexadecimal notation is
{
12345678901234
:x
}
."
f"
{
12345678901234
}
in 0x-hexadecimal notation is
{
12345678901234
:#x
}
."
f"
{
1234567890
}
in binary notation is
{
1234567890
:b
}
."
f"
{
1234567890
}
in 0b-binary notation is
{
1234567890
:#b
}
."
f"
{
5
}
+
{
4
}
=
{
5
+
4
}
"
from
math
import
pi
f"pi is approximately
{
pi
}
."
f"pi rounded to two decimals is
{
pi
:.2f
}
."
f"1/321 as percentage with 2 decimals is
{
1
/
321
:.2%
}
."
f"1.2345533e4 with thousand separator and 1 decimal is
{
1.2345533e4
:,.1f
}
."
from
math
import
sin
f"sin(0.25pi) is approximately
{
sin
(
0.25
*
pi
):.5f
}
."
f"
{
1.2359817e12
}
is
{
1.2359817e12
:e
}
and approximately
{
1.2359817e12
:.3g
}
."
f"Single braces without expression: {{ and }}."
f"
{
5
+
4
=
}
"
f"
{
23
*
sin
(
2
-
5
)
=
}
"
f"
{
1
<
5
}
is True and
{
1
+
5
}
= 6."
# The last str function example
Back
|
FazBrowse Home
|
New Git URL