FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/conditionals/if_else_nested.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
/
conditionals
/
if_else_nested.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
20 lines (17 loc) · 840 Bytes
Breadcrumbs
programmingWithPythonCode
/
conditionals
/
if_else_nested.py
Copy path
File metadata and controls
20 lines (17 loc) · 840 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
"""An example of using the nested `if-else` statements."""
a
:
int
=
13
# the first number
b
:
int
=
7
# the second number
c
:
int
=
9
# the third number
if
a
>
b
:
# This means that a > b
if
a
>
c
:
# This means that a > b and a > c.
print
(
f"
{
a
}
is the greatest number."
)
else
:
# This means that a > b and c >= a.
print
(
f"
{
c
}
is the greatest number."
)
else
:
# This means that b >= a.
if
b
>
c
:
# This means that b >= a and b > c.
print
(
f"
{
b
}
is the greatest number."
)
else
:
# This means that b >= a and c >= b.
print
(
f"
{
c
}
is the greatest number."
)
# Some side information: The max and min function are very useful.
print
(
f"The maximum is
{
max
(
a
,
b
,
c
)
}
."
)
# max: get the largest element
print
(
f"The minimum is
{
min
(
a
,
b
,
c
)
}
."
)
# min: get te smallest element
Back
|
FazBrowse Home
|
New Git URL