Thursday, August 4, 2011

LPTHW - Exercise 6

In the last exercise, we learned about variables and also introduced String formatting. In this exercise, we learn more about Strings and text.

First, I typed the program as is, and got the expected output.



Extra Credit:

Next, I commented the code, and also counted the number of times we put a String inside a String (it is indeed four times).



Some Observations:
  • When we concatenate multiple Strings a space character is not added between them, the way print adds it, when we try to print multiple Strings. So if we want to print multiple Strings without spaces between them, then we should concatenate them with the + operator and print the concatenated result.
Some questions:

1 comment: