Hannah's Chapter 2 Exercises

by Hannah Wang

18 Jan 2016

Most of my issues with this assignment arose from assignment and expression statements, as well as the concept of concatenation of string variables. In exercise 2, I was struggling to print both “Hello” and “(name)”, without having them be two separate expression statements. Before I had the lightbulb moment about concatenation, the closest I got was:

print('Hello')
print(name)

This returned “Hello (name)” on two separate lines. I finally remembered what the reading had said about “+” with string variables performing concatenation, rather than addition, and ended up with this!

In exercise 3, I had two separate problems: how to make the variables for hours and rate into operands, and then how to get the variable for pay to print with the word “Pay: “, which is a string. I used this example from here to help: http://ils.unc.edu/~eah13/textbook/02-variables.html#asking-the-user-for-input. In this example, the user input for speed has to be defined as an integer before it can interact with another integer variable. After this realization, getting the input variable for pay to print with “Pay: “ was pretty straightforward, because it was very similar to the print statement in the previous exercise.

Exercise 5 was the simplest for me, perhaps because I now had a better understanding of variables. I used assignment statements to make the input for the Celsius temperature an integer, and to make the resulting temperature in Fahrenheit a string.

I really enjoyed the problem-solving aspects of this assignment! :thumbsup: :sunny:

Hannah Wang is a second semester MSIS student at SILS. Find Hannah Wang on Twitter, Github, and on the web.