Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8805915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:59:13+00:00 2026-06-14T01:59:13+00:00

Just for fun, I am trying to take the python calculator program written below

  • 0

Just for fun, I am trying to take the python calculator program written below and convert it to PHP.

Can anyone help me out/ is this possible?

The program is below and I want to get the same output by but with PHP.

#!/usr/bin/env python
#
#title: calculator.py
#author: Samuel Peppard
#purpose:
#

# 1 equates a loop, everything else does not.
loop = 1 

# Contains the player's choice
choice = 0 

while loop == 1:

# Print what options you have
print " "
print "Basic Calculator Program!"

print " "
print "Select your function by typing its designated number..."

print " "
print "1) Addition"
print "2) Subtraction"
print "3) Multiplication"
print "4) Division"
print "5) Quit"
print " "

# allows for raw input to be read
choice = int(raw_input("Choose your option: ").strip())

if choice == 1:
    add1 = input("Add this amount: ")
    add2 = input("to this amount: ")
    print " "
    print add1, "+", add2, "=", add1 + add2

elif choice == 2:
    sub2 = input("Subtract this amount: ")
    sub1 = input("from this amount: ")
    print " "
    print sub1, "-", sub2, "=", sub1 - sub2

elif choice == 3:
    mul1 = input("Multiply this amount: ")
    mul2 = input("with this amount: ")
    print " "
    print mul1, "*", mul2, "=", mul1 * mul2

elif choice == 4:
    div1 = input("Divide this amount: ")
    div2 = input("by this amount: ")
    print " "
    print div1, "/", div2, "=", div1 / div2

elif choice == 5:
    loop = 0

print "Goodbye for now!"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:59:15+00:00Added an answer on June 14, 2026 at 1:59 am

    Taking your second question:

    is this possible?

    Of course it is. Both PHP and python are turing complete, and both can take console input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a jquery plugin (just for fun) and I can't seem
Just for fun, I wrote this simple function to reverse a string in Python:
Just for fun, how close can we get to debug an application in C#
I built (just for fun) 3 classes to help me log some events in
I'm writing some code (just for fun so far) in Python that will store
I am (just for fun) trying to implement a High Score web-service. I would
Just for fun I was trying to write a one line with std::find_if with
For just some fun i am trying to use Flat File databases to read
I'm trying to convert Chinese lunar system to Gregorian using Perl, both for fun
Ok so I am just trying to learn some of this fun stuff now,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.