Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sample_641
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
adith.s
Sample_641
Commits
3dec1ced
Commit
3dec1ced
authored
Aug 24, 2021
by
adith.s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
sample.py
+85
-0
No files found.
sample.py
0 → 100644
View file @
3dec1ced
def
add
(
a
,
b
):
"""
Function to add two numbers
:param a: First value
:param b: Second value
:return: return the value of Addition
"""
return
a
+
b
def
sub
(
a
,
b
):
"""
function to subtract two numbers
:param a: First value
:param b: Second Value
:return: returns the value of subtraction
"""
if
a
>
b
:
"""A condition is checked whether first number is greater to avoid negative values
if first number is greater then subtraction is done
"""
d
=
a
-
b
return
d
else
:
print
(
"First number should be Greater"
)
def
mul
(
a
,
b
):
"""
:param a: First value
:param b: second value
:return: returns the product
"""
return
a
*
b
def
div
(
a
,
b
):
"""
:param a: First value
:param b: Second Value
:return: the quotient and remainder is got
"""
if
b
==
0
:
print
(
"Zero divison cannot be done"
)
else
:
f
=
a
/
b
print
(
"The Quotient is "
,
f
)
g
=
a
%
b
print
(
"The remainder is"
,
g
)
a
=
True
while
a
:
a
=
int
(
input
(
"enter first number"
))
b
=
int
(
input
(
"enter second number"
))
print
(
" Please Select the operation"
)
print
(
"1.Addition"
)
print
(
"2.Subtraction"
)
print
(
"3.Multiplication"
)
print
(
"4.Divison (Quotient and Remainder)"
)
print
(
"Choose Your Option"
)
z
=
int
(
input
())
if
z
==
1
:
print
(
"The Sum is"
,
add
(
a
,
b
))
elif
z
==
2
:
print
(
"The difference is"
,
sub
(
a
,
b
))
elif
z
==
3
:
print
(
"The Product is "
,
mul
(
a
,
b
))
elif
z
==
4
:
(
div
(
a
,
b
))
s
=
input
(
"do you want to exit?(yes or no)"
)
if
(
s
==
"yes"
):
a
=
False
elif
(
s
==
"no"
):
a
=
True
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment