Computers & Internet Logo

Related Topics:

Posted on Sep 28, 2011

Sample of how to create a python program that will input two numbers and will ask the user of operation to perform as to addition,subtraction,multiplication or division the program should perform the require operation and display the result.

1 Answer

Anonymous

Level 1:

An expert who has achieved level 1.

New Friend:

An expert that has 1 follower.

Corporal:

An expert that has over 10 points.

Mayor:

An expert whose answer got voted for 2 times.

  • Contributor 13 Answers
  • Posted on Sep 28, 2011
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

New Friend:

An expert that has 1 follower.

Corporal:

An expert that has over 10 points.

Mayor:

An expert whose answer got voted for 2 times.

Joined: Sep 27, 2011
Answers
13
Questions
0
Helped
1258
Points
24

Assuming that the input numbers are given by the user:print "Menu"print "1. Addition"print "2. Subtraction"print "3. Multiplication"print "4. Division"print "0. Quit"
a = input("Please make a selection:")if a == 1: x = input("Please enter a number:") y = input("Please enter another number:") answer = x + yprint "%r plus %r = %r" % (x,y,answer)elif a == 2: x = input("Please enter a number:") y = input("Please enter another number:") answer = x - yprint "%r minus %r = %r" % (x,y,answer)
The same goes for everything else just with different signs. Don't forget that "*" is multiplication and "/" is division. Also, for 0. Just use:
elif a == 0: quit

  • Anonymous Sep 28, 2011

    Menu
    1. Addition
    2. Subtraction
    3. Multiplication
    4. Division
    0. Quit
    Please make a selection:1
    Please enter a number:1
    Please enter another number:1
    1 plus 1 = 2
    >>>

  • Anonymous Sep 28, 2011

    That will be the result. The numbers at the end of the colons are user inputs.

×

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

166 views

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

ADMIN Andrew
ADMIN Andrew

Level 3 Expert

73783 Answers

ADMIN Eric
ADMIN Eric

Level 3 Expert

42221 Answers

Brad Brown

Level 3 Expert

19190 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...