String Formating

  1. Assume you have a variable x that refers to an integer. Write code to print out the value of x surrounded by arrows. E.g., if the value of x is 7, you should print this:

    -->7<--

    Use %d as the specifier in the format string.
  1. Given two integers v1 and v2, use string formatting to create a string values showing the values of v1 and v2 with a ‘, ‘ between (a comma and a space).
    Make sure you put your values in a tuple.
  1. If v1 = 1, v2 = 3.75, and v3 = “hi”, create a string in variable resStr with value hi! 1 != 3.75 :-(.
    Put your three values in a tuple in the order v3, v1, v2. To make sure you have only 2 digits after the decimal, use this format specifier: %.2f
  1. If v1 = 1, and v2 = 2, create a string in variable resStr which refers to variable 1 is 1 (1.0) and variable 2 is 2 (2.0).

    To make sure you have only 1 digit after the decimal, use this format specifier: %.1f

    You can use a variable multiple times in the same tuple.