Variables and constants
Q1. What must all variable names and constants begin with? What can be used after the first character? What can't be used?
Q2. How many key words are there in Python?
Q3. What is the significance of the set of keywords in Python as far as choosing a good variable or constant name is concerned?
Q4. Can a variable name in Python have more than 12 characters?
Q5. Can a variable name in Python use a space e.g. length of car?
Q6. Using the Internet for research, find three characters from the keyboard that you are not allowed to use in a variable name. Try using them in the Python shell.
Q7. How do you assign the value 3.14 to indicate that this is a constant value called pi which shouldn't change?
Q8. Show how you would assign 12 to a constant for months in the year in Python. Test it out in the Python shell by assigning 12 to your constant and then printing it.
Q9. Can you actually change a constant value? Try changing the number of months constant by adding 1 to it, and then printing it out. Did it work?
Q10. Declare a constant in the Python shell:
WEEKS_IN_YEAR = 52
Now find out what id number Python has allocated to WEEKS_IN_YEAR like this:
Q11. Assign two variables and two constants to some values. Use id to see what number Python has allocated to each of them.
Q12. It is worth knowing about the id() function. Sometimes, two objects that appear different are actually the same. The way to check is to use the id() function on each object and see if they really are the same or different. Do some research. Find out a little bit more about the id() function and its uses.