Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Python-mini-projects
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue 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
dhana surya
Python-mini-projects
Commits
9b77ab24
Commit
9b77ab24
authored
2 months ago
by
dhana surya
Browse files
Options
Downloads
Patches
Plain Diff
maths logic is added
parent
0757f6f2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cs50-python-problem-set/problem-set-1/interpreter.py
+14
-2
14 additions, 2 deletions
cs50-python-problem-set/problem-set-1/interpreter.py
with
14 additions
and
2 deletions
cs50-python-problem-set/problem-set-1/interpreter.py
+
14
−
2
View file @
9b77ab24
# to create a math interpreter
# TODO Prompt the usr for the input
expression
=
input
(
"
Enter the arithmetic operation (x , y , z )
:
"
)
expression
=
input
(
"
Enter the arithmetic operation
(+ , - , * , / ) in format
(x , y , z ):
"
)
# TODO phrase the input into the component (x , y , z )
x
,
y
,
z
=
expression
.
split
(
"
"
)
x
,
z
=
int
(
x
)
,
int
(
z
)
# type casting the two value
print
(
type
(
x
)
,
type
(
z
))
# TODO Evaluate the arithmetic expression
if
y
==
"
+
"
:
result
=
x
+
z
elif
y
==
"
-
"
:
result
=
x
-
z
elif
y
==
"
*
"
:
result
=
x
*
z
elif
y
==
"
/
"
:
result
=
x
/
z
else
:
print
(
"
Enter the proper format OR this progam can do only the basic calculation
"
)
# TODO Format and output the result into the one decimal place
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