Question: Using python and a while loop only, Templates: #PROBLEM 1 def pairs(l1): list1 = l1 return 0 #YOUR CODE GOES HERE (indented) return l1 #END
Using python and a while loop only,
Templates:
#PROBLEM 1 def pairs(l1): list1 = l1 return 0 #YOUR CODE GOES HERE (indented) return l1 #END YOUR CODE #PROBLEM 2 def replaceAll(l1,l2): string1 = l1 string2 = l2 #YOUR CODE GOES HERE (indented) return string1 #END YOUR CODE
| Problem 1: | Write code that checks every adjacent pair of numbers in a list to see if either is a factor of the other and returns all factor-pairs in order. For example, the list [2, 6, 12, 3, 7, 8, 16, 10]would yield ["2-6", "6-12", "3-12", "8-16"]. You may not use any built-in functions/methods besides len() and .append(). |
| Problem 2: | Write code that takes two strings from the user, replaces all instances of the second string with box in the first. For example, happymondayhappyday and happy yields the result boxmondayboxday. We will guarantee the second string will be less than four characters long. You may not use the built-in replace function. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
