100% found this document useful (1 vote)
33 views

Coding Club Level 2 Python Next Steps Roffey C. instant download

The document is an introduction to the 'Coding Club Level 2 Python: Next Steps' book by Chris Roffey, aimed at teaching Python programming to children aged 12-13 and older learners. It covers essential programming concepts, including data types, building GUIs, and creating a simple calculator, while encouraging hands-on coding and problem-solving. The book includes downloadable resources and projects to enhance learning and understanding of Python programming.

Uploaded by

otakebouvykt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
33 views

Coding Club Level 2 Python Next Steps Roffey C. instant download

The document is an introduction to the 'Coding Club Level 2 Python: Next Steps' book by Chris Roffey, aimed at teaching Python programming to children aged 12-13 and older learners. It covers essential programming concepts, including data types, building GUIs, and creating a simple calculator, while encouraging hands-on coding and problem-solving. The book includes downloadable resources and projects to enhance learning and understanding of Python programming.

Uploaded by

otakebouvykt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Coding Club Level 2 Python Next Steps Roffey C.

download

https://ebookname.com/product/coding-club-level-2-python-next-
steps-roffey-c/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Next generation video coding and streaming 1st Edition


Bing

https://ebookname.com/product/next-generation-video-coding-and-
streaming-1st-edition-bing/

Leading Your Business to the Next Level Rodney Page

https://ebookname.com/product/leading-your-business-to-the-next-
level-rodney-page/

Embedded C Coding Standard Michael Barr

https://ebookname.com/product/embedded-c-coding-standard-michael-
barr/

Rockets and People Hot days of the cold war First


English Language Edition. Edition Boris Chertok

https://ebookname.com/product/rockets-and-people-hot-days-of-the-
cold-war-first-english-language-edition-edition-boris-chertok/
Smooth Homogeneous Structures in Operator Theory 1st
Edition Daniel Beltita

https://ebookname.com/product/smooth-homogeneous-structures-in-
operator-theory-1st-edition-daniel-beltita/

Geomancist SECOND EDITION A Fated Mates Paranormal


Series 7 Forbidden Arts A Paranormal Romance Series
Book 5 Charmaine Pauls

https://ebookname.com/product/geomancist-second-edition-a-fated-
mates-paranormal-series-7-forbidden-arts-a-paranormal-romance-
series-book-5-charmaine-pauls/

Pll Performance Simulation and Design 3rd Edition Dean


Banerjee

https://ebookname.com/product/pll-performance-simulation-and-
design-3rd-edition-dean-banerjee/

The Secrets of Getting Better Grades Study Smarter Not


Harder 2nd Edition Brian Marshall

https://ebookname.com/product/the-secrets-of-getting-better-
grades-study-smarter-not-harder-2nd-edition-brian-marshall/

Focus on Grammar 2 Workbook A2 4th Edition Samuela


Eckstut-Didier

https://ebookname.com/product/focus-on-grammar-2-workbook-a2-4th-
edition-samuela-eckstut-didier/
Java Web Services Up and Running Second Edition Martin
Kalin

https://ebookname.com/product/java-web-services-up-and-running-
second-edition-martin-kalin/
Cod
i
Clu ng
Python b

Next
Steps level 2
Chris Roffey
Cod
i
Clu ng
Python b

Next
Steps level 2
Chris Roffey
University Printing House, Cambridge CB2 8BS, United Kingdom

Cambridge University Press is part of the University of Cambridge.


It furthers the University’s mission by disseminating knowledge in the pursuit of
education, learning and research at the highest international levels of excellence.

www.cambridge.org
Information on this title: www.cambridge.org/9781107623255
© Cambridge University Press 2013
This publication is in copyright. Subject to statutory exception
and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.
First published 2013
Reprinted 2013
Printed in Poland by Opolgraf
A catalogue record for this publication is available from the British Library
ISBN 978-1-107-62325-5 Paperback
Cambridge University Press has no responsibility for the persistence or accuracy
of URLs for external or third-party internet websites referred to in this publication,
and does not guarantee that any content on such websites is, or will remain,
accurate or appropriate.
Contents
Introduction 4

Chapter 1: Data types 7

Chapter 2: Building GUIs 21

Chapter 3: Designing a simple calculator 36

Chapter 4: A fully working calculator 47

Chapter 5: Customising the calculator 61

Bonus chapter: Algorithms 74

Taking things further 90

Appendix 1: Some key bits of information 91

Appendix 2: Binary numbers 94

Appendix 3: Calculator functions source code 96

Glossary and index 99

The Quick Quiz answers 105

Acknowledgements 106
Contents 3
Introduction
Who is this book for?
This book is the Level 2 core book in the Coding Club series of books. To get the most out
of this title, you should be familiar with the Python 3 programming language and know
about variables, while loops and if, elif and else statements. Therefore, we advise that you
first read Python Basics before reading this book. Python: Next steps is aimed at 12–13 year
olds but is accessible to older children and even adults who want to learn about computer
programming.

Why should you choose this book?


This book explains important principles while helping you build useful short projects. We
want you, the reader, to learn not only how to make the programs in this book but also
how to design your own. We want you to be able to write programs well, so that if you take
it further and become the inventor of the next Google you will not have to unlearn bad
programming habits.

Introduction 4
What you need?
Any computer can run Python 3. If your computer does not already have Python 3 installed
there is a section on the companion website (www.codingclub.co.uk) that guides you through
the installation. This takes about five minutes! That is all you need to get started.

Start files for all the projects in the book are available to download from the companion
website so you do not get lost in the bigger projects. There are also finished files for each
project, should you get stuck, and answers to the puzzles and challenges.

How to use this book


You should read this book carefully and build all the main projects in order. At the end of
each chapter there are further ideas, and challenges that you can think of as ‘mini quests’.
Some readers will want to work through them all so that they understand everything all the
time. Some of you will probably prefer to rush through and get to the end. Which approach
is best? The one you are most comfortable with is the best approach for you. If you are being
guided by a teacher, you should trust their judgement so that you can get the most help out
of them as possible.

There are four ways in which this book tries to help you to learn:

1 Typing in the code – this is important as it gets you to work through the code a line at a
time (like computers do) and will help you remember the details in the future.
2 Finding and fixing errors – error messages in Python give you some clues as to what has
gone wrong. Solving these problems yourself will help you to be a better programmer.
However, if you get stuck, the code can be downloaded from the companion website
(www.codingclub.co.uk).
Introduction 5
3 Experimenting – feel free to experiment with the code you write. See what else you can
make it do. If you try all the challenges, puzzles and ideas, and generally play with the
code, this will help you learn how to write code like a professional.
4 Finally, this book will not only provide the code to build some pretty cool, short projects –
it will also teach you how the programs were designed. You can then use the same
methods to design your own applications.

A word of warning
You may be tempted to simply get the code off the website instead of typing it out yourself.
If you do this you will probably find that you cannot remember how to write code so easily
later. In this book you will only be asked to type small chunks of code at a time – remember
that this will help you understand every detail of each of your programs.

Introduction 6
Chapter 1
Data types
In this chapter you will:

• learn about data types

• learn about tuples, lists and dictionaries

• make a version of MyMagic8Ball that is much shorter than the one from Python Basics.

Data types
In Python Basics you learned about strings (bits of text), integers (whole numbers) and
I’m back!
floats (numbers with a decimal point). These are examples of data types. There are more!
In this chapter we will look at some new data types: tuples, lists and dictionaries. These new
data types are all called container data types because they store more than one piece of
data. For example, they can store several strings. They do so in different ways and have their
own advantages and disadvantages.

A string is rather like a container because it stores a whole sequence of letters or numbers (or
a mixture of both). In Python Basics we learned that there are several functions we can use on
strings. We can also use many of these functions on tuples, lists and dictionaries.
Chapter 1: Data types 7
Tuples
A tuple is the simplest of our new data types. They can store strings, integers and other data
types. Here is an example of a tuple that stores four strings, each separated by a comma:

my_tuple = ("one", "two", "three", "four")

Each value in a tuple is separated by a comma. Unlike variables, we cannot change what is
stored in a given tuple.

Each value in the tuple has an index starting from 0. So, print(my_tuple[1])for the
example above produces the output two. Look at how this works below.

Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07)


[GCC 4.4.5] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
>>> my_tuple = ("one", "two", "three", "four")
>>> print(my_tuple[0])
one
>>> print(my_tuple[1])
two
>>> print(my_tuple[2])
three
>>> print(my_tuple[3])
four
>>>

A tuple.
Chapter 1: Data types 8
MyMagic8Ball
In Python Basics we wrote a small application called MyMagic8Ball that used the random
module and the functions print(), input() and randint(). Here is the code:

Code Box 1.1


# My Magic 8 Ball

import random

# write answers
ans1="Go for it!"
ans2="No way, Jose!"
ans3="I'm not sure. Ask me again."
ans4="Fear of the unknown is what imprisons us."
ans5="It would be madness to do that!"
ans6="Only you can save mankind!"
ans7="Makes no difference to me, do or don't - whatever."
ans8="Yes, I think on balance that is the right choice."

print("Welcome to MyMagic8Ball.")

# get the user's question


question = input("Ask me for advice then press ENTER to shake me.\n")

(continues on the next page)

Chapter 1: Data types 9


print("shaking ...\n" * 4)

# use the randint() function to select the correct answer


choice=random.randint(1, 8)
if choice==1:
answer=ans1
elif choice==2:
answer=ans2
elif choice==3:
answer=ans3
elif choice==4:
answer=ans4
elif choice==5:
answer=ans5
elif choice==6:
answer=ans6
elif choice==7:
answer=ans7
else:
answer=ans8

# print the answer to the screen


print(answer)

input("\n\nPress the RETURN key to finish.")

Chapter 1: Data types 10


Now see how much easier and shorter the code is if we include a tuple:

Code Box 1.2


# My Magic 8 Ball

import random

# put answers in a tuple

answers = (
"Go for it!",
"No way, Jose!",
"I'm not sure. Ask me again.",
"Fear of the unknown is what imprisons us.",
"It would be madness to do that!",
"Only you can save mankind!",
"Makes no difference to me, do or don't - whatever.",
"Yes, I think on balance that is the right choice."
)

print("Welcome to MyMagic8Ball.")

# get the user's question


question = input("Ask me for advice then press ENTER to shake me.\n")

print("shaking ...\n" * 4)

# use the randint() function to select the correct answer


choice = random.randint(0, 7)

(continues on the next page)

Chapter 1: Data types 11


# print the answer to the screen
print(answers[choice])

# exit nicely
input("\n\nPress the RETURN key to finish.")

Analysis of Code Box 1.2


If it has been a while since you read Python Basics, you might find it useful to type this code
into IDLE and think about it line by line. Here is what it does.

The import statement

We are going to use a function from Python’s random module so we need to import it.

The tuple

We have to separate the strings in the tuple answers with commas. Starting a new line after
each comma makes the code much easier to read.

The input() function

The input() function listens to the keyboard entry and waits for the return key to be
pressed. It then returns the keyboard input as a string, which we store in the variable
question.

Chapter 1: Data types 12


question = input("Ask me for advice then press ENTER to shake me.\n") Are you are a bit confused
about when to use round brackets
and when to use square brackets?
variable name to access string that is printed out, Basically, when we create a tuple we
the keyboard input giving instructions to the user wrap its contents in round brackets.
Whenever we call an indexed value
from the tuple, we put the index
The randint() function (its position in the list) in square
brackets.
choice = random.randint(0, 7)

This line of code asks the randint() method in the random module to select a random
number from 0 to 7. This number is then stored in the variable called choice. (A method is
a function in a class.)

Finishing off

print(answers[choice])

This uses the random number choice as the index in the answers tuple. This line selects
the string that was randomly chosen from the tuple and prints it.

Experiment
The two scripts are available from the companion website
(www.codingclub.co.uk). Try them both out and check that they
do the same thing.

Chapter 1: Data types 13


Lists Hmm, the list is surrounded by
square brackets this time.
A list is another type of container. They are very similar to tuples except that they can be
altered. Think of tuples as quick, memory-efficient lists that cannot be altered by other code.
We cannot insert or delete items in tuples with our programs. There are, however, functions
to allow us to insert or delete items in lists. Lists are written like this:

my_list = ["one", "two", "three", "four"]

Just as with tuples, each value in the list has an index starting from 0 and each value is
separated by a comma.

Look at how this works in interactive mode:

>>> my_list = ["one", "two", "three", "four"]


Do you remember that interactive mode
>>> my_list[2] in Python means using the Python shell rather
'three' than saving and running a file? It is very
>>> my_tuple = ("one", "two", "three", "four") useful for running little experiments.
>>> my_tuple[2]
'three'
>>>

You can see that both a list and a tuple provide the same output. So, when would we use a
list instead of a tuple? We would choose a list rather than a tuple if we want our program to
add, remove or change an item within the list.

Chapter 1: Data types 14


Quick Quiz 1.1
For each of the following say which is the best choice, a list or a tuple:
1 A place to store seven strings consisting of the days of the week (e.g. "Monday") that we
want to use in an application.
2 A place to store the full names of members of the Coding Club in an application we use to
keep track of who is still a club member.
3 A place to store the ten integer values (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9) of the keys used to
make a calculator app.

Silly me, I was confused


for a moment here as I
Dictionaries had forgotten that strings
always appear in speech
The last of our container data types is a dictionary. Dictionaries take a slightly marks and numbers do
different form. In dictionaries we supply our own indexes. Here, we call the index a key. not. So 1 is an integer but
"1" is a number stored
Keys can be strings, integers, floats or even tuples. Here is an example:
as a string!
key value

my_dictionary = {1:"cat", 2:"dog", 3:"horse", 4:"fish"}

or
key value

my_dictionary = {"1":"cat", "2":"dog", "3":"horse", "4":"fish"}

Chapter 1: Data types 15


Look at how this works in interactive mode:

>>> my_dictionary = {1:"one", 2:"two", 3:"three", 4:"four"}


>>> my_dictionary[2]
'two'
>>> my_dictionary = {"1":"one", "2":"two", "3":"three", "4":"four"}
>>> my_dictionary["2"]
'two'

You might have noticed that dictionaries require a different structure within the brackets to
assign keys to the values. They use a colon ‘:’ to separate the value from its key.

What’s with the brackets?


When we create a new container, Python provides us with a quick way of defining which
kind we require by our choice of brackets.

• If you want a tuple – wrap it in round brackets.

• If you want a list – use square brackets.

• If it’s a dictionary you are after – use curly brackets.

Chapter 1: Data types 16


Delving Deeper
What’s the difference?
Strings, tuples and lists are all indexed ordered containers; the values are automatically given an index
based on the order in which they were input. Dictionaries have keys that you provide and the key–value
pairs are not stored in a particular order. Strings and tuples have their content set at creation and cannot be
changed by a program directly. Lists and dictionaries are containers in which the values can be added to and
changed in a variety of ways.
It is also possible to create empty containers like this:
my_string = ""
my_tuple = ()
my_list = []
my_dictionary = {}

Useful functions
Table 1.1 provides a list of useful functions you can use on strings, tuples, lists and
dictionaries. You can also find it in Appendix 1. The table assumes the following containers
have been created:

>>> s = "bar" # a string


>>> t = ("b", "a", "r") # a tuple
>>> l = ["b", "a", "r"] # a list
>>> d = {1:"b", 2:"a", 3:"r"} # a dictionary

Chapter 1: Data types 17


Function Strings Tuples Lists Dictionaries
print all >>> print(s) >>> print(t) >>> print(l) >>> print(d)
bar ('b', 'a', 'r') ['b', 'a', 'r'] {1: 'b', 2: 'a', 3: 'r'}
print >>> print(s[2]) >>> print(t[2]) >>> print(l[2]) >>> print(d[2])
element r r r a
combine >>> a=s+"f" >>> a=t+("f",) >>> a=l+["f"]
>>> a >>> a >>> a
'barf' ('b', 'a', 'r', 'f') ['b', 'a', 'r', 'f']
add an Strings cannot Tuples cannot be >>> l.append("f") >>> d[4]="f"
element be altered. altered. >>> l >>> d[4]
['b', 'a', 'r', 'f'] 'f'
sort Strings cannot Tuples cannot be >>> l.sort() >>> sorted(d)
be altered. altered. >>> l ['1', '2', '3']
['a', 'b', 'r'] >>> sorted(d.values()) This table could be very
['a', 'b', 'r'] helpful when I write
delete an Strings cannot Tuples cannot be >>> del l[1] >>> del d[1] my own applications!
element be altered. altered. >>> l >>> i
['b', 'r'] {2:'a', 3:'r'}
replace Strings cannot Tuples cannot be >>> l[0]="c" >>> d[1]="c"
element be altered. altered. >>> l >>> print(d)
['c', 'a', 'r'] {1: 'c', 2: 'a', 3: 'r'}
find >>> i.find("b") >>> t.index("b") >>> l.index("b")
0 0 0
get >>> len(s) >>> len(t) >>> len(l) >>> len(d)
length 3 3 3 3

Table 1.1 Some useful functions.


s = "bar" # a string
t = ("b", "a", "r") # a tuple
l = ["b", "a", "r"] # a list
d = {1:"b", 2:"a", 3:"r"} # a dictionary
Chapter 1: Data types 18
Quick Quiz 1.2
For each of the following say whether to choose a tuple, a list, or a dictionary:
1 A container to store the personal best times achieved by club swimmers in the 100m
freestyle such as: Mark: 65.34s, Freya: 68.04s, etc.
2 A container to store the months of the year.
3 A container to store the monthly rainfall data for London in 2012.
4 A container to store the names of the students who currently attend the chess club.

Chapter summary
In this chapter you have:

• learned more about data types


• learned about tuples, lists and dictionaries
• made a shorter version of MyMagic8Ball
• seen some of the different functions that can and cannot be used with the new It is always good
data types. to practise.

We will explore these new data types further in this book. Here are just a few ideas
that will help you refresh your coding skills from Python Basics. (As dictionaries are the
hardest to use, we will wait until you have learned a little bit more before providing any
puzzles involving them.)

Chapter 1: Data types 19


Puzzle
Write a new version of MyMagic8Ball using a list instead of a tuple. It should work in exactly
the same way if you get it right because lists can do everything tuples can and more.

Challenge
This is a challenge from Python Basics so although you may be a bit rusty you should be
able to manage it. Hopefully it brings back happy memories for you.
1 Add some code to myMagic8Ball2.py (Code Box 1.2) so that the Magic8Ball says “Hi”
and asks for the user’s name at the start of the game.
2 It should then store the input in a variable such as user_name.
3 Change the code so that the Magic8Ball talks to the user using their name. At the end
for example, it could say: “Thanks for playing, [Name]. Please press the RETURN key to
finish.”
You are destined to
There are several ways to do this. become a famous computer
To see one answer go to www.codingclub.co.uk/book2_resources.php. scientist one day!

Idea
Change the Magic8Ball game into a fortune cookie game. You could call it
myFortuneCookie.py.

Chapter 1: Data types 20


Chapter 2
Building GUIs
In this chapter you will:

• practise using tuples and dictionaries

• revise how to use tkinter and learn about using widgets

• build a graphical user interface (GUI)

• build a glossary application.

Chapter 2: Building GUIs 21


MyGlossary
A graphical user interface (GUI) is, very simply, the ‘screen’ that allows a user to interact
with their computer through graphics such as menus and buttons. You are now going to
build a small GUI application of your own using tkinter.

In the source code downloaded from the companion website, in the folder for Chapter 2,
you will find a file called myGlossary_Start.py. This file provides you with outline source
code for a glossary application containing the complete glossary for this book. This is also
provided for reference in Code Box 2.1.

Code Box 2.1


# myGlossary_Start.py

from tkinter import *

# key press function:

##### main:
window = Tk()
window.title("My Coding Club Glossary")

# create label

# create text entry box

# Add a submit button:

Chapter 2: Building GUIs 22


# create another label It is useful to be able to
choose whether to wrap
strings in single or double
# create text box speech marks. Don’t
forget to be consistent in
# The dictionary: your code though.
my_glossary = {
'algorithm': 'Step by step instructions to perform a task that a
computer could understand.',
'bug': 'A piece of code that is causing a program to fail to run
properly or at all.',
'binary number': 'A number represented in base 2.'
}

##### Run mainloop


window.mainloop()

The glossary has been stored as a dictionary data type. The key is the glossary word and the
value is the definition.

e.g. 'function': 'A reusable piece of code'

key value

We have used single speech marks rather than the usual double ones so that we can use
double speech marks in the definitions without having to escape them all.

Chapter 2: Building GUIs 23


Discovering Diverse Content Through
Random Scribd Documents
suitable wood limits the manufacture of such wares now, but they
are still in use.
Cedar was long one of the best woods for skiffs and other light
boats, and it was occasionally employed in shipbuilding for the upper
parts of vessels. A little of it is still used as trim and finish,
particularly for canoes, motor boats, and yachts.
The early clothes chest makers selected clear lumber, because it
could be had and was considered to be better; but modern chest
manufacturers who cannot procure clear stock, make a merit of
necessity, and use boards filled with knots. The wood is finished with
oils, but the natural colors remain, and the knots give the chest a
rustic and pleasing appearance.
Southern Red Juniper (Juniperus barbadensis) so closely resembles the red cedar
with which it is associated that the two were formerly considered the same
species, and most people familiar with both notice no difference. However,
botanists clearly distinguish the two. The southern red cedar’s range is much
smaller than the other’s. It grows from Georgia to the Indian river, Florida, in
swamps. It is found in the vicinity of the Apalachicola river, forming dense thickets.
Its average size is much under that of the red cedar, but its wood is not dissimilar.
It has been used for the same purposes as far as it has been used at all. One of
the largest demands upon it has been for lead pencils. Those who bought and sold
it, generally supposed they were dealing in the common red cedar.
NORTHERN WHITE CEDAR

Northern White Cedar


NORTHERN WHITE CEDAR
(Thuja Occidentalis)

his tree is designated as northern white cedar because there is

T also a southern white cedar, (Chamæcyparis thyoides) and the


boundaries of their ranges approach pretty closely. The name
occidentalis, meaning western, applied to the northern white
cedar is employed by botanists to distinguish it from a similar
cedar in Asia, which is called orientalis, or eastern.
The American species has several names, as is usual with trees
which grow in different regions. It is called arborvitæ in Maine,
Vermont, Massachusetts, Rhode Island, Connecticut, New York, New
Jersey, Pennsylvania, Delaware, Virginia, West Virginia, Indiana,
Illinois, Wisconsin, Michigan, Minnesota, Ohio, and Ontario. White
cedar is a name often used in Maine, New Hampshire, Vermont,
Rhode Island, Massachusetts, New York, New Jersey, Virginia, North
Carolina, Wisconsin, Michigan, Minnesota, and Ontario. In Maine,
Vermont, and New York it is called cedar. In New York, and where
cultivated in England, American arborvitæ is the name applied to it.
The Indians in New York knew it as feather-leaf. In Delaware the
name is abridged to vitæ.
The tree has been widely planted, and under the influence of
cultivation it runs quickly into varieties, of which forty-five are listed
by nurserymen. It is a northern species which follows the
Appalachian mountains southward to North Carolina and Tennessee.
It grows from New Brunswick to Manitoba, and is abundant in the
Lake States.
The bark of arborvitæ is light brown, tinged with red on the
branchlets; it is thin, and cracks into ridges with stringy, rough
edges; the branchlets are very smooth.
In general appearance the tree is conical and compact, with short
branches; it attains a height of from twenty-five to seventy feet, and
a diameter of from one to three feet. It thrives best in low, swampy
land, along the borders of streams.
The wood of arborvitæ is soft, brittle, light and weak; it is very
inflammable. The fact that it is durable, even in contact with the soil,
permits its use for railway ties, telegraph poles, posts, fencing,
shingles and boats. However, the trunk is so shaped that it is seldom
used for lumber, but oftener for poles and posts, the lower section
being flattened into ties. A cubic foot of the seasoned wood weighs
approximately nineteen pounds. The heartwood is light brown,
becoming darker with exposure; the sapwood is thin and nearly
white, with fine grain.
The northern white cedar varies greatly in size and shape,
depending on the soil, climate, and situation. Though it is usually
associated with swamps in the North, it adapts itself to quite
different situations. It grows in narrow, rocky ravines, on stony
ridges, and it clings to the faces of cliffs, or hangs on their summits
as tenaciously as the western juniper of the Sierra Nevada
mountains. However, little good timber is produced by this species
on rocky soils. Trees in such situations are short, crooked, and limby.
The wood of the northern white cedar possesses a peculiar
toughness which is seen in its wearing qualities. A thin shaving, such
as a carpenter’s plane makes, may be folded, laid on an anvil, and
struck repeatedly with a hammer, without breaking. It is claimed for
it that it will stand a severer test of that kind than any other
American wood. Toughness and wearing qualities combined make it
an admirable wood for planking and decking for small boats. Its
exceptionally light weight is an additional factor as a boat building
material. The Indians knew how to work it into frames for bark
canoes. Its lightness appealed to them; but the ease with which they
could work it with their primitive tools was more important. It is a
characteristic of the wood to part readily along the rings of annual
growth. The Indian was able to split canoe ribs with a stone maul,
by pounding a cedar billet until it parted along the growth rings and
was reduced to very thin slats.
The property of this cedar which appealed to the Indians is disliked
by the sawmill man. It is hard to make thin lumber that will hang
together. The tendency to part along the growth rings develops
wind-shake while the tree is standing. About nine trees in ten are so
defective from shake that little good lumber can be made from
them. It is a common saying, which probably applies in certain
localities only, that a thousand feet of white cedar must be sawed to
get one hundred feet of good lumber.
It is good material for small cooperage such as buckets, pails, and
tubs, and has been long used for that purpose in the northern
states.
It was once laid in large quantities for paving blocks. Hundreds of
miles of streets of northern cities were paved with round blocks
sawed from trunks of trees from five to ten inches in diameter. They
were not usually treated with chemicals to prevent decay, but they
gave service ranging from six to twelve years. They are less used
now than formerly. Southern yellow pine has largely taken the
cedar’s place as paving material. Much northern cedar has been
used in the manufacture of bored pipe for municipal waterworks,
shops, salt works, paper mills, and other factories.
The early settlers of New Jersey and eastern Pennsylvania made a
rheumatism ointment by bruising the leaves and molding them with
lard. This is probably not made now, but pharmacists distill an oil
from twigs and wood, and make a tincture of the leaves which they
use in the manufacture of pulmonary and other medicines.
There is little likelihood that northern white cedar will ever cease to
be a commercial wood in this country. It will become scarcer, but its
manner of growth is the best guarantee that it will hold its place. It
lives in swamps, and the land is not in demand for any other
purpose.
One-Seed Juniper (Juniperus monosperma) is also called naked-seed juniper. Its
range lies in Colorado, New Mexico, Texas, Utah, and Arizona. It attains its
greatest development in the bottoms of canyons in northern Arizona. It is a
scrawny desert tree which lives in adversity but holds its ground for centuries, if
fire does not cut its career short. Its growth is too scattered to attract lumbermen,
and the form of its trunk is uninviting. It may reach a height of forty or fifty feet,
and a diameter of three, but that is above the average in the best of its range. The
desert Indians make the most of one-seed juniper. They weave its stringy bark
into sleeping mats, rough blankets, and saddle girts. They make cords and ropes
of it for use where great strength is not required, such as leashes for leading dogs,
strands with which to tie bundles on the backs of their squaws, and cords for
fastening their wigwam poles together. They likewise weave the bark into pokes
and pouches for storing and carrying their dried meat and mesquite beans. The
juniper berries are an article of diet and commerce with the Indians, who mix
them with divers ingredients, pulp them in stone mortars, and bake them in cakes
which become the greatest delicacy on their bill of fare. White men, when driven
to it by starvation, have sustained life by making food of the berries. A small
quantity of one-seed juniper reaches woodworkers in Texas. The lumber is short
and rough. The numerous knots are generally much darker than the body of the
wood. That is not necessarily a defect, for in making clothes chests, the striking
contrast in color between the knots, and the other wood gives the article a
peculiar and attractive appearance. The trunks are sharply buttressed and deeply
creased. Sometimes the folds of bark within the creases almost reach the center of
the tree. The sapwood is thin, the heartwood irregular in color. Some is darker
than the heartwood of southern red cedar, other is clouded and mottled, pale
yellow, cream-colored, the shade of slate, or streaked with various tints. The wood
can be economically worked only as small pieces. It takes a soft and pleasing
finish. It is a lathe wood and shows to best advantage as balusters, ornaments,
grill spindles and small posts, Indian clubs, dumb-bells, balls, and lodge gavels. It
has been made into small game boards with fine effect, and it is an excellent
material for small picture frames. Furniture makers put it to use in several ways,
and it has been recommended for small musical instruments where the variegated
colors can be displayed to excellent advantage. At the best it can never be more
than a minor species, because it is difficult of access in the remote deserts, and it
is not abundant.
Mountain Juniper (Juniperus sabinoides) is a Texas tree, occupying a range
southward and westward of the Colorado river. It has several local names, rock
cedar being a favorite. This name is due to the tree’s habit of growing on rocky
ridges and among ledges where soil is scarce. It is called juniper cedar, and
juniper. Under the most favorable circumstances the tree may attain a height of
100 feet and a diameter of two, but it nearly always grows where conditions are
adverse, and its size and form change to conform to circumstances. It is often
small and ragged. Its lead-colored bark is apt to attract attention on account of its
woeful appearance, hanging in strings and tatters which persistently cling to the
trunk in spite of whipping winds. When the tree is cut for fuel, or for any other
purpose, the ragged bark is occasionally pulled off and is tied in bales or bundles
to be sold for kindling. When the mountain juniper is taken from its native wilds
and planted where environments are different, it sometimes assumes fantastic
forms. It has been planted for ornament on the low, flat coast in the vicinity of the
Gulf of Mexico, and though it lives and grows, it often takes on a peculiar
appearance. The trunks resemble twisted and interwoven bundles of lead-colored
vines, buttressed, fluted, and gnarled. The branches lose their upright position,
and hang in careless abandon, with drooping festoons. In winter the wind whips
most of the foliage from them. The leaves become brittle and may be easily
brushed from the twigs by a stroke of the hand. Some of the planted trees have
trunks so deeply creased as to be divided in two separate stems. This very nearly
happens with some of the wild trees among the western mountains. The sapwood
of mountain juniper is very thin. The average tree cannot be profitably cut into
lumber of the usual dimensions because of the odd-shaped and irregular trunk. It
lends itself more economically to the manufacture of articles made up of small
pieces. Some of the wood is extremely beautiful, having the color and figure of
French walnut; but there is great difference in the figure and color, and the wood
of one tree is not a sure guide to what another may be. Boards a foot wide, or
even less, may show several figures and colors. Some pieces suggest variegated
marble; others are like plain red cedar; some are light red in color, others have a
tinge of blue. It varies greatly in hardness, even in the same tree. Part of it may
be soft and brittle enough for lead pencils; another part may be hard and tough.
Clothes chests have been made of it, of most peculiar appearance—resembling
crazy quilts of subdued colors. Sometimes the heartwood and the sapwood are
inextricably mixed, both being found in all parts of the trunk from the heart out.
On the whole, the tree can never have much importance as a source of lumber,
but it is a most interesting member of the cedar group.
SOUTHERN WHITE CEDAR

Southern White Cedar


SOUTHERN WHITE CEDAR
(Chamæcyparis Thyoides)

his tree is called southern white cedar to distinguish it from

T northern white cedar or arborvitæ. When there is little


likelihood of confusion, the name white cedar is applied locally
in different parts of its range from Massachusetts to Florida. It
is a persistent swamp tree and on that account has been
called swamp cedar; but that name alone would not distinguish it
from the northern white cedar, for both grow in swamps; but it does
separate it from red cedar which keeps away from swamps. The
ranges of the two are side by side from New England to Florida. Post
cedar is a common name for it in Delaware and New Jersey, because
of the important place it has long filled as fence material; but again,
the name does not set it apart from red cedar or northern white
cedar, for both are used for posts. The only name thus far applied,
which clearly distinguishes it from associated cedars, is southern
white cedar. Its range extends northward to Maine, but the tree’s
chief commercial importance has been in New Jersey and southward
to North Carolina, very near the coast. Somehow, it seems to skip
Georgia where no one has reported it for many years, though there
is historical evidence that it once grew in that state. It grows as far
west as Mississippi, but is scarce.
The small leaves remain green two years and then turn brown but
adhere to the branches several years longer. The fruit is about one-
fourth inch in diameter, and the small seeds are equipped with
wings.
The wood is among the lightest in this country. It is only moderately
strong and stiff. The tree usually grows slowly. Fifty years may be
required to produce a fence post, but under favorable conditions
results somewhat better than that may be expected. The
summerwood of the yearly ring is narrow, dark in color, and
conspicuous, making the counting of the rings an easy matter. The
medullary rays are numerous but thin. When the sap is cut
tangentially in very thin layers it is white and semi-transparent,
presenting somewhat the appearance of oiled paper. The heartwood
is light brown, tinged with red, growing darker with exposure. The
wood is easily worked, and is very durable in contact with the soil.
Fence posts of this wood have been reported to stand fifty years,
and shingles are said to last longer. Trees reach a height of eighty
feet and diameter of four; but such are of the largest size. Great
numbers are cut for poles and posts which are little more than a foot
in diameter. Few forest trees grow in denser stands than this. It
often takes possession of swamps, crowds out all other trees, and
develops thickets so dense as to be almost impenetrable. Southern
white cedar is cut in ten or twelve states, but the annual supply is
not known, because mills generally report all cedars as one, and the
regions which produce this, produce one or more other species of
cedar also. It has held its place nearly three hundred years, and
much interesting history is connected with it. A considerable part of
the Revolutionary war was fought with powder made from white
cedar charcoal burned in New Jersey and Delaware. However, that
was by no means the earliest place filled by this wood.
Two hundred years ago in North Carolina John Lawson wrote of its
use for “yards, topmasts, booms, bowsprits for boats, shingles, and
poles.” It was cut for practically the same purposes in New Jersey at
an earlier period, and 160 years ago Gottlieb Mittelberger, when he
visited Philadelphia, declared that white cedar was being cut at a
rate which would soon exhaust the supply. But that prophecy, like
similar predictions that oak and red cedar were about gone, proved
not well founded. Seventy years after the imminent exhaustion of
this wood was foretold, William Cobbett, an English traveler, declared
with evident exaggeration that “all good houses in the United States”
were roofed with white cedar shingles.
After boat building, the first general use of the southern white cedar
was for fences and farm buildings, and doubtless twenty times as
much went to the farms as to the boat yards. In all regions where
the wood was convenient, little other was employed as fencing
material, and many of the earliest houses in New Jersey and some in
Pennsylvania were constructed almost wholly of this wood. Small
trees which would split two, three, and four rails to the cut, were
mauled by thousands to enclose the farms. The bark soon dropped
off, or was removed, and the light rails quickly air-dried, and decay
made little impression on them for many years. The larger trunks
were rived for shingles or were sawed into lumber. About 1750 the
use of round cedar logs for houses and barns began to give way to
sawed lumber. It was an ideal milling timber, for the logs were
symmetrical, clear, and easily handled. North Carolina sawmills were
at work on this timber many years before the Revolution. It was
acceptable material for doors, window frames, rafters, and floors,
but especially for shingles which were split with frow and mallet, and
were from twenty-four to twenty-seven inches long. They were
known in market as juniper shingles and sold at four and five dollars
a thousand. About 1750 builders in Philadelphia were criticized
because they constructed houses with no provision for other than
white cedar roofs; the walls being too weak for heavier material
which would have to be substituted when cedar could be no longer
procured. Philadelphia was not alone in its preference for cedar
roofs. Large shipments of shingles were going from New Jersey to
New York, and even to the West Indies earlier than 1750.
Southern white cedar is said to have been the first American wood
used for organ pipes. The resonance of cedar shingles under a
pattering rain suggested this use to Mittelberger when he visited
America, and he tried the wood with such success that he
pronounced it the best that he knew of for organ pipes.
Coopers were among the early users of white cedar. The “cedar
coopers of Philadelphia” were famous in their day. They used this
wood and also red cedar (Juniperus virginiana), and their wares
occupied an important place in domestic and some foreign markets.
Small vessels prevailed, such as pails, churns, firkins, tubs, keelers,
piggins, noggins, and kegs. The ware was handsome, strong,
durable, and light in weight. Oil merchants, particularly those who
dealt in whale oil which was once an important commodity, bought
tanks of southern white cedar. It is a dense wood and seepage is
small.
A peculiar superstition once prevailed, and has not wholly
disappeared at this day, that white cedar possessed powerful healing
properties. It was thought that water was purified by standing in a
cedar bucket, and even that a liquid was improved by simply running
through a spigot of this wood. Some eastern towns at an early
period laid cedar water mains, partly because the wood was known
to be durable, and partly because it was supposed to exercise some
favorable influence upon the water flowing through the pipes. It was
even believed that standing trees purified the swamps in which they
grew. Vessels putting to sea from Chesapeake bay, sometimes made
special effort to fill their water casks with water from the Dismal
swamp, where cedars grew abundantly in the stagnant lagoons.
About 100 years ago it was found that whole forests of cedar had
been submerged in New Jersey during prehistoric times, and that
deep in swamps the trunks of trees were buried out of sight. No one
knows how long the prostrate trees had lain beneath the
accumulation of peat and mud, but the wood was sound. Mining the
cedar became an important industry in some of the large swamps,
and it has not ended yet. The wood is sound enough for shingles
and lumber, though it has been buried for centuries, as is proved by
the age of the forests which grew over the submerged logs.
Sometimes a log which has lain under water hundreds of years, rises
to the surface by its own buoyancy when pressure from above is
removed. This is remarkable and shows how long a time this cedar
resists complete waterlogging. The wood of green cedar has a
strong odor, and that characteristic remains with the submerged
trunks. Experienced men who have been long engaged in mining the
timber, are able to tell by the odor of a chip brought to the surface
from a deeply submerged log whether the wood is sufficiently well
preserved to be worth recovering and manufacturing. Trunks six feet
in diameter have been brought to the surface. Few if any living white
cedars of that size exist now.
Many of the early uses of southern white cedar have continued till
the present time, but in much smaller quantities. Fence rails are no
longer made of it; shingles and cooperage have declined. On the
other hand, it now has some uses which were unknown in early
times, such as telephone and telegraph poles, crossties, and piling
for railroad bridges and culverts.
The supply of southern white cedar is not large, and it is being cut
faster than it is growing. The deep swamps where it grows protect
white cedar forests from fire, and for that reason it is more fortunate
than many other species. Not even cypress can successfully compete
with it for possession of water soaked morasses. It does not promise
great things for the future, for it will never be extensively planted.
Its range has been pretty definitely fixed by nature to deep swamps
near the Atlantic coast. Within those limits it will be of some
importance for a long time. Where it finds its most congenial
surroundings, little else that is profitable to man will grow. This will
save it from utter extermination, because much of the land which it
occupies will never be wanted for anything else.
INCENSE CEDAR

Incense Cedar
INCENSE CEDAR
(Libocedrus Decurrens)

n California and Oregon this tree is known as white cedar, cedar,

I and incense cedar; in Nevada and California it is called post


cedar and juniper, and in other localities it is red cedar and
California post cedar. It is a species of such strong
characteristics that it is not likely to be confused with any other.
Though different names may be applied to it, the identity of the tree
is always clear.
Its range extends north and south nearly 1,000 miles, from Oregon
to Lower California. It is a mountain species, and it faces the Pacific
ocean in most of its range. In the North it occupies the western
slope of the Cascade mountains in southern Oregon and northern
California; and it grows on the western slope of the Sierras for five
hundred miles, at altitudes of from 4,000 to 8,000 feet, where it is
mixed with sugar pine, western yellow pine, white fir, and sequoias.
It is a fine, shapely tree, except that the butt is much enlarged. It
has the characteristic form of a deep swamp tree, but it has nothing
to do with swamps. Its best development is on the Sierra Nevada
mountains, where swamps are few, and the incense cedar avoids
them. It occupies dry ridges and slopes, but not sterile ones. It must
have as good soil as the sugar pine demands. Its height when
mature ranges from seventy-five to 125 feet, diameter four feet from
the ground, from three to six feet, but some trees are larger. It is
not a rapid grower, but it maintains its vigor a long time. As an
average, it increases its diameter an inch in from seven to ten years.
The wood is dense. It contains no pores large enough to be seen
with an ordinary reading glass. The medullary rays are so small as to
be generally invisible to the naked eye, but when magnified they are
shown to be thin and numerous. The summerwood forms about
one-fourth of the annual ring. The wood is nearly as light as white
pine, is moderately strong, is brittle, straight grained, the heartwood
is reddish, the thick sapwood nearly white. It is an easy wood to
work, and in contact with the soil it is very durable.
The incense cedar is the only representative of its genus in the
United States. It has many relatives in the pine family, but no near
ones. Its kin are natives of Formosa, China, New Zealand, New
Guinea, and Patagonia.
The name incense cedar refers to the odor of the wood rather than
of the leaves. Those who work with freshly cut wood are liable to
attacks of headache, due to the odor; but some men are not
affected by it.
The forest grown tree is of beautiful proportions. Unless much
crowded for room, it is a tall, graceful cone, the branches drooping
slightly, and forming thick masses. In the Sierra Nevada mountains,
within the range of this cedar, the winter snows are very heavy. It is
not unusual for two or three feet of very wet snow to fall in a single
day. The incense cedar’s drooping branches shed the snow like a
tent roof, and a limb broken or seriously deformed by weight of
snow is seldom seen. Deer and other wild animals, when surprised
by a heavy fall of snow, seek the shelter of an incense cedar, if one
can be found, and there lie in security until the storm passes.
It is a tree which does fairly well in cultivation, and several varieties
have been developed. It lives through the cold of a New England
winter. Its cones are about three-fourths inch in length, and ripen in
the autumn.
Incense cedar has filled an important place in the development of
the great central valley of California, where it has supplied more
fence posts than any other tree. Posts of redwood have been its
chief competitor, but generally the region has been divided, and
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like