September 2013
Intermediate to advanced
350 pages
9h 38m
English
Here are some exercises for you to try on your own. Solutions are available at http://pragprog.com/titles/gwpy2/practical-programming.
Write a program that makes a backup of a file. Your program should prompt the user for the name of the file to copy and then write a new file with the same contents but with .bak as the file extension.
Suppose the file alkaline_metals.txt contains the name, atomic number, and atomic weight of the alkaline earth metals:
| | beryllium 4 9.012 |
| | magnesium 12 24.305 |
| | calcium 20 20.078 |
| | strontium 38 87.62 |
| | barium 56 137.327 |
| | radium 88 226 |
Write a for loop to read the contents of alkaline_metals.txt and store it in a list of lists, with each inner list containing the name, atomic number, and atomic weight ...
Read now
Unlock full access