FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python_Programs/pricePerUnit2.py at main · MayankVerma105/Python_Programs · GitHub
MayankVerma105
/
Python_Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
5
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Python_Programs
/
pricePerUnit2.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (23 loc) · 716 Bytes
Breadcrumbs
Python_Programs
/
pricePerUnit2.py
Copy path
File metadata and controls
24 lines (23 loc) · 716 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
import
sys
def
main
():
price
=
input
(
'Enter price of the item'
)
weight
=
input
(
'Enter weight of the item'
)
try
:
if
price
==
''
:
price
=
None
price
=
float
(
price
)
if
weight
==
''
:
weight
=
None
weight
=
float
(
weight
)
assert
price
>=
0
and
weight
>=
0
result
=
price
/
weight
except
ValueError
:
print
(
'Invalid inputs : ValueError'
)
except
TypeError
:
print
(
'Invalid inputs : TypeError'
)
except
ZeroDivisionError
:
print
(
'Invalid inputs : ZeroDivisionError'
)
except
:
print
(
str
(
sys
.
exc_info
()))
else
:
print
(
'Price per unit weight'
,
result
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL