Excercise 1-1
Excercise 1-1
It is a good idea to read this book in front of a computer so you can try out the examples as you
go. Whenever you are experimenting with a new feature, you should try to make mistakes.
For example, in the “Hello, world!” program, what happens if you leave out one of the quotation
marks? What if you leave out both? What if you spell print wrong?
This kind of experiment helps you remember what you read; it also helps when you are
programming, because you get to know what the error messages mean. It is better to make
mistakes now and on purpose than later and accidentally.
Questions:
1. In a print statement, what happens if you leave out one of the parentheses, or both?
Here yo can see if you leave without one parenthesis bring out a unmatched error
3. If you are trying to print a string, what happens if you leave out one of the quotation marks,
or both?
Here yo can see it bring out a error for unterminated string or no defined what it is in the
print
4. You can use a minus sign to make a negative number like -2. What happens if you put a
plus sign before a number? What about 2++2?
5. In math notation, leading zeros are okay, as in 02. What happens if you try this in Python?
6. What happens if you have two values with no operator between them?