Well, the WSQ03 was basicaly do a program that will recieve 2 numbers, and sum, rest, multiply, and divide them; very basic, real quick, but since I am very stubborn, I wantdel blog wordpress sueschefftruthed to create a software that does not allow you to type anything but integers. Obviously, this was not going to be a 5 minute task, so here we go..

So the two key points where I wanted to base my program were:

  • Just input integers, except for the name and other decitions
  • It gives you the choice to start the program again

So for the first part, the one with just integers, I first had to figure out how will the computer detect it is a float, and since every input in python is a string, I couldn’t just ask the type as type(x), so I used the “in” function to chek if in any of the variable was a “.” stored in  “e”:

in for float

Then, the hardest part came in, figure out how the banana i was going to tell the program the input was not a string, little problem, all inputs are strings!, so I asked aid from Bauer, and he pointed me in the right direction with this python webpage: https://docs.python.org/2/tutorial/errors.html

And here is the part:

while try number

And the last key point, the ability to reload, was pretty easy. I just used a variable named choice and asigned a lowercased string that if it is yes, the whole problem runs againwith a while:

choice while

The rest, was pretty much a piece of pizza:

And that’s it!

CC BY 4.0 First code of the semester WSQ03 by charliegdrummer is licensed under a Creative Commons Attribution 4.0 International License.