The day I had fun with numbers was a day of no internet connection at TEC. Luckily it was an assignment I was able to do without the help of Google. I just needed Ken’s guidance and my previous knowledge.

42numbersatom

42numberscygwin

What was new this time was input(), concatenation of strings and variables in an output, and some operations signs.

We use input() when we ask data from the user, I knew raw_input() from Python 2, but it doesn’t exist in Python 3, it is now just input(). Previously raw_input() returned a string, but now input() can detect that the user entered an integer. I converted it to int as routine but it is actually not necessary on Python 3.

To concatenate strings you join them with + signs, when you print an output, you can concatenate strings and variables, just be careful, strings need to be inside (” “) and variables do not, but they do need to become a string (if they aren’t already),by doing str(variable) to print everything smoothly.

When you want to get the integer result of a division, that is called floor division, and it can be performed by the operation sign //.

When you want the remainder of an operation, you need the modulo. This is its operation sign %.

CC BY 4.0 WSQ03 by carminaperezguerrero is licensed under a Creative Commons Attribution 4.0 International License.