ICP 1 - adrian6912/CS490PythonML GitHub Wiki

This wiki page is for the first ICP1 submission.

  1. The differences between Python 2 and 3 are mostly syntax in nature. For instance, the print function in Python 2 doesn't require parentheses, while in Python 3 it does. Another difference is in the way the two versions implement integer division. In Python 2, integer division returns the floor of the quotient unless the two numbers are explicitly stated as being floating point, ex: 3/2 = 1. In Python 3, integer division will automatically return a floating point as the quotient when it is required, ex: 3/2 = 1.5. There are many other differences, but there are too many to list here.

  2. My program, which is the function "play", takes the word "Python" when inputted by the user, removes the letters 'n' and 'h', and returns the string reversed using [::-1]. For the second section, the function "arith" takes two inputs from the user (which naively assumes that the inputs are integers...) and prints the resulting sum.

  3. This is implemented with the function "replacer". It asks for a sentence from the user contains the word 'python' and replaces it with 'pythons'. This is done by first splitting the input into a list, then iterating through the list, testing to see if it is 'python', and then adding it a new list along with the other elements that aren't altered. Then, the function iterates through the new list and creates a new string using the elements from that list.