Download ebooks file (Ebook) Learn Python Programming: A beginner's guide to learning the fundamentals of Python language to write efficient, high-quality code by Romano, Fabrizio ISBN 9781786468161, 9781788294874, 9781788996662, 9782118716141, 9782507622992, 1786468166, 1788294874, 1788996666, 2118716141 all chapters
Download ebooks file (Ebook) Learn Python Programming: A beginner's guide to learning the fundamentals of Python language to write efficient, high-quality code by Romano, Fabrizio ISBN 9781786468161, 9781788294874, 9781788996662, 9782118716141, 9782507622992, 1786468166, 1788294874, 1788996666, 2118716141 all chapters
com
DOWLOAD EBOOK
ebooknice.com
ebooknice.com
https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
ebooknice.com
ebooknice.com
(Ebook) Cambridge IGCSE and O Level History Workbook 2C -
Depth Study: the United States, 1919-41 2nd Edition by
Benjamin Harrison ISBN 9781398375147, 9781398375048,
1398375144, 1398375047
https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044
ebooknice.com
https://ebooknice.com/product/learn-python-programming-7316112
ebooknice.com
ebooknice.com
https://ebooknice.com/product/functional-python-programming-efficient-
python-code-56115518
ebooknice.com
Learn Python Programming
Second Edition
Fabrizio Romano
BIRMINGHAM - MUMBAI
Learn Python Programming
Second Edition
Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers
and distributors, will be held liable for any damages caused or alleged to have been caused
directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals. However,
Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78899-666-2
www.packtpub.com
To my dear dear friend and mentor, Torsten Alexander Lange.
Thank you for all the love and support.
mapt.io
Mapt is an online digital library that gives you full access to over
5,000 books and videos, as well as industry leading tools to help you
plan your personal development and advance your career. For more
information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical
eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
You'll meet the same wise and caring guide in this book. Every
chapter, every example, every explanation has been carefully thought
out, driven by a desire to impart the best and most accurate
understanding of the technology, and to do it with kindness. Fab
takes you under his wing to teach you both Python's syntax and its
best practices.
I'm also impressed with the scope of this book. Python has grown
and evolved over the years, and it now spans an enormous
ecosystem, being used for web development, routine data handling,
and ETL, and increasingly for data science. If you are new to the
Python ecosystem, it's often hard to know what to study to achieve
your goals. In this book, you will find useful examples exposing you
to many different uses of Python, which will help guide you as you
move through the breadth that Python offers.
I hope you will enjoy learning Python and become a member of our
global community. I'm proud to have been asked to write this, but
above all, I'm pleased that Fab will be your guide.
Naomi Ceder
Python Software Foundation Fellow
Contributors
About the author
Fabrizio Romano was born in Italy in 1975. He holds a master's
degree in computer science engineering from the University of
Padova. He is also a certified scrum master, Reiki master and teacher,
and a member of CNHC.
I'm grateful to all those who helped me create this book. Special thanks to Dr. Naomi Ceder
for writing the foreword to this edition, and to Heinrich Kruger and Julio Trigo for reviewing
this volume. To my friends and family, who love me and support me every day, thank you.
And to Petra Lange, for always being so lovely to me, thank you.
About the reviewers
Heinrich Kruger was born in South Africa in 1981. He obtained a
bachelor's degree with honors from the University of the
Witwatersrand in South Africa in 2005 and a master's degree in
computer science from Utrecht University in the Netherlands in 2008.
I would like to thank my parents for their love, good advice, and continuous support. I would
also like to thank all the friends I have met along the way, who enriched my life, for keeping
up my motivation, and make me progress.
Packt is searching for authors
like you
If you're interested in becoming an author for Packt, please visit
authors.packtpub.com and apply today. We have worked with thousands of
developers and tech professionals, just like you, to help them share
their insight with the global tech community. You can make a general
application, apply for a specific hot topic that we are recruiting an
author for, or submit your own idea.
Table of Contents
1. Title Page
6. Contributors
1. About the author
2. About the reviewers
3. Packt is searching for authors like you
7. Preface
1. Who this book is for
4. An extensive library
5. Software quality
6. Software integration
7. Satisfaction and enjoyment
4. What are the drawbacks?
5. Who is using Python today?
3. Numbers
1. Integers
2. Booleans
3. Real numbers
4. Complex numbers
5. Fractions and decimals
4. Immutable sequences
1. Strings and bytes
1. Encoding and decoding strings
2. Indexing and slicing strings
3. String formatting
2. Tuples
5. Mutable sequences
1. Lists
2. Byte arrays
6. Set types
7. Mapping types – dictionaries
8. The collections module
1. namedtuple
2. defaultdict
3. ChainMap
9. Enums
10. Final considerations
1. Small values caching
2. How to choose data structures
1. Positional arguments
2. Keyword arguments and default values
3. Variable positional arguments
4. Variable keyword arguments
5. Keyword-only arguments
6. Combining input parameters
7. Anonymous functions
8. Function attributes
9. Built-in functions
10. One final example
11. Documenting your code
12. Importing objects
1. Relative imports
13. Summary
5. Saving Time and Memory
1. The map, zip, and filter functions
1. map
2. zip
3. filter
2. Comprehensions
1. Nested comprehensions
2. Filtering a comprehension
3. dict comprehensions
4. set comprehensions
3. Generators
1. Generator functions
2. Going beyond next
3. The yield from expression
4. Generator expressions
4. Some performance considerations
5. Don't overdo comprehensions and generators
6. Name localization
7. Generation behavior in built-ins
8. One last example
9. Summary
6. OOP, Decorators, and Iterators
1. Decorators
1. A decorator factory
2. Object-oriented programming (OOP)
1. The simplest Python class
2. Class and object namespaces
3. Attribute shadowing
4. Me, myself, and I – using the self variable
5. Initializing an instance
1. Static methods
2. Class methods
10. Private methods and name mangling
11. The property decorator
12. Operator overloading
13. Polymorphism – a brief overview
3. Unit testing 
1. Writing a unit test
2. Mock objects and patching
3. Assertions
4. Testing a CSV generator
1. Boundaries and granularity
2. Testing the export function
3. Final considerations
2. Test-driven development
3. Exceptions
4. Profiling Python
1. When to profile?
5. Summary
2. Token generation
3. Digest comparison
4. HMAC
5. JSON Web Tokens
1. Registered claims
1. Time-related claims
2. Auth-related claims
1. Properties of a process
5. Multithreading or multiprocessing?
3. Concurrent execution in Python
1. Starting a thread
2. Starting a process
3. Stopping threads and processes
1. Stopping a process
4. Spawning multiple threads
5. Dealing with race conditions
6. A thread's local data
7. Thread and process communication
1. Thread communication
2. Sending events
2. Assertions
7. Where to find information
2. Troubleshooting guidelines
1. Using console editors
2. Where to inspect
3. Using tests to debug
4. Monitoring
3. Summary
12. GUIs and Scripts
1. First approach – scripting
1. The imports
2. Parsing arguments
4. Threading considerations
4. Summary
13. Data Science
1. IPython and Jupyter Notebook
1. Installing the required libraries
2. Using Anaconda
3. Starting a Notebook
2. Dealing with data
1. Setting up the Notebook
2. Preparing the data
3. Cleaning the data
4. Creating the DataFrame
I wanted this book to not just be about the language but about
programming. The art of programming, in fact, comprises many
aspects, and language is just one of them.
With all these goals in mind, I then had to face the hardest
challenge: take all the content I wanted to write and make it fit in the
amount of pages that were allowed. It has been tough, and sacrifices
were made.
And now, I have written the second edition of this book, and this
time, I had a little more space. So I decided to add a chapter about
IO, which was desperately needed, and I even had the opportunity to
add two more chapters, one about secrets and one about concurrent
execution. The latter is definitely the most challenging chapter in the
whole book, and its purpose is that of stimulating the reader to reach
a level where they will be able to easily digest the code in it and
understand its concepts.
I have kept all the original chapters, except for the last one that was
slightly redundant. They have all been refreshed and updated to the
latest version of Python, which is 3.7 at the time of writing.
When I look at this book, I see a much more mature product. There
are more chapters, and the content has been reorganized to better fit
the narrative, but the soul of the book is still there. The main and
most important point, empowering the reader, is still very much
intact.
I hope that this edition will be even more successful than the
previous one, and that it will help the readers become great
programmers. I hope to help them develop critical thinking, great
skills, and the ability to adapt over time, thanks to the solid
foundation they have acquired from the book.
Who this book is for
Python is the most popular introductory teaching language in the top
computer science universities in the US, so if you are new to software
development, or if you have little experience and would like to start
off on the right foot, then this language and this book are what you
need. Its amazing design and portability will help you to become
productive regardless of the environment you choose to work with.
If you have already worked with Python or any other language, this
book can still be useful to you, both as a reference to Python's
fundamentals, and for providing a wide range of considerations and
suggestions collected over two decades of experience.
Exploring the Variety of Random
Documents with Different Content
seventy-five years, is 3,293,000,000 miles from the sun when in
aphelion, and only 54,770,000 miles when in perihelion.
Comets, when near the sun, are greatly affected by the disturbing
attraction of large planets, and especially of the most massive of
them all, Jupiter. The effect of this disturbance is to change the form
of their orbits, with the not infrequent result that the latter are
altered from apparent parabolas into unquestionable ellipses, and
thus the comets concerned are said to be “captured,” or made
prisoners to the sun, by the influence of the disturbing planet. About
twenty small comets are known as “Jupiter's Comet Family,” because
they appear to have been “captured” in this way by him. A few
others are believed to have been similarly captured by Saturn,
Uranus, and Neptune.
The orbits of comets differ from those of the planets in other ways
beside their greater eccentricity. The planets all move round the sun
from west to east, but comets move in both directions. The orbits of
the planets, with the exception of some of the asteroids, all lie near
one common plane, but those of comets are inclined at all angles to
this plane, some of them coming down from the north side of the
ecliptic and others up from the south side.
A comet consists of two distinct portions: first, the head, or
nucleus; and, second, the tail. The latter only makes its appearance
when the comet is drawing near the sun, and, as a whole, it is
always directed away from the sun, but usually more or less curved
backward along the comet's course, as if the head tended to run
away from it. The appearance of a comet's tail at once suggests that
it is produced by some repulsive force emanating from the sun.
Recently there has been a tendency to explain this on the principle
of what is known as the pressure of light. This demands a brief
explanation. Light is believed to be a disturbance of the universal
ether in the form of waves which proceed from the luminous body.
These waves possess a certain mechanical energy tending to drive
away bodies upon which they impinge. The energy is relatively
slight, and in ordinary circumstances produces no perceptible effect,
but when the body acted upon by the light is extremely small the
pressure may become so great relatively to gravitation as to prevail
over the latter. To illustrate this, let us recall two facts—first, that
gravitation acts upon the mass, i.e. all the particles of a body
throughout its entire volume; and, second, that pressure acts only
upon the exterior surface. Consequently gravitation is proportional to
the volume, while the pressure of light is proportional to the surface
of the body acted upon. Now the mass, or volume, of any body
varies as the cube of its diameter, and the surface only as the
square. If, then, we have two bodies, one of which has twice the
diameter of the other, the mass of the second will be eight times less
than that of the first, but the surface will be only four times less. If
the second has only one-third the diameter of the first, then its mass
will be twenty-seven times less, but its surface only nine times less.
Thus we see that as we diminish the size of the body, the mass falls
off more rapidly than the area of the surface, and consequently the
pressure gains relatively to the gravitation. Experiment has
corroborated the conclusions of mathematics on this subject, and
has shown that when a particle of matter is only about one one-
hundred-thousandth of an inch in diameter the pressure of light
upon it becomes greater than the force of gravitation, and such a
particle, situated in open space, would be driven away from the sun
by the light waves. This critical size would vary with the density of
the matter composing the particle, but what we have said will serve
to convey an idea of its minuteness.
Now in applying this to comets' tails it is only necessary to remark
that they are composed of either gaseous or dusty particles, or both,
rising from the nucleus, probably under the influence of the heat or
the electrical action of the sun, and these particles, being below the
critical size, are driven away from the sun, and appear in the form of
a tail following the comet. It may be added that the same principle
has been evoked to explain the corona of the sun, which may be
composed of clouds of gas or dust kept in suspension by the
pressure of light.
The nuclei of comets contain nearly their whole mass. The actual
mass of no comet is known, but it can in no case be very great.
Moreover, it is probable that the nucleus of a comet does not consist
of a single body, either solid or liquid, but is composed of a large
number of separate small bodies, like a flock of meteors, crowded
together and constantly impinging upon one another. As the comet
approaches the sun the nucleus becomes violently agitated, and
then the tail begins to make its appearance.
The possibility exists of an encounter between the earth and the
head of a comet, but no such occurrence is known. Two or three
times, however, the earth is believed to have gone through the tail
of a comet, the last time in 1910, when Halley's comet passed
between the earth and the sun, but no certain effects have been
observed from such encounters. The spectroscope shows that
comets contain various hydrocarbons, sodium, nitrogen, magnesium,
and possibly iron, but we know, as yet, very little about their
composition. The presence of cyanogen gas was reported in Halley's
comet at its last appearance. We are still more ignorant of the origin
of comets. We do know, however, that they tend to go to pieces,
especially those which approach very close to the sun. The great
comet of 1882, which almost grazed the sun, was afterward seen
retreating into space scattered into several parts, each provided with
a tail. In at least one case, several comets have been found
travelling in the same track, an indication that one large original
comet has been separated into three or four smaller ones. This
appears to be true of the comets of 1843, 1880, and 1882,—and
perhaps the comet of 1576 should be added. But the most
remarkable case of disruption is that of Biela's Comet, which first
divided into two parts in 1846 and then apparently became scattered
into a swarm of meteors which was encountered by the earth in
1872, when it passed near the old track of the comet. This leads us
to our next subject.
8. Meteors. Everybody must, at some time, have beheld the
phenomenon known as a falling, or shooting, star. A few of these
objects can be seen darting across the sky on almost any clear night
in the course of an hour or two of watching. Sometimes they appear
more numerously, and at intervals they are seen in “showers.” They
are called meteors, and it is believed that they are minute solid
bodies, perhaps averaging but a small fraction of an ounce in
weight, which plunge into the atmosphere with velocities varying
from twenty to thirty or more miles per second, and are set afire and
consumed by the heat of friction developed by their rush through
the air. Anybody who has seen a bullet melted by the heat suddenly
developed when it strikes a steel target has had a graphic illustration
of the transformation of motion into heat. But if we could make the
bullet move fast enough it would melt in the air, the heat being
developed by the constant friction.
The connection of meteors with comets is very interesting. In the
year 1833, a magnificent and imposing display of meteors, which,
for hours, on the night between the 13th and 14th of November,
filled the sky with fire-balls and flaming streaks, astonished all
beholders and filled many with terror. It was found that these
meteors travelled in an orbit intersecting that of the earth at the
point where the latter arrived in the middle of November, and also
that they had a period of revolution about the sun of 33¼ years,
and were so far scattered along their orbit that they required nearly
three years to pass the point of intersection with the orbit of the
earth. Thus it was concluded that for three years in succession, in
mid-November, there should be a display of the meteors plunging
into the earth's atmosphere. But only in the year when the thickest
part of the swarm was encountered by the earth would the display
be very imposing. Upon this it was predicted that there would be a
recurrence of the phenomenon of 1833 in the year 1866. It
happened as predicted, except that the number of meteors was not
quite so great as before. In the meantime, it had been discovered
that these meteors followed in the track of a comet known as
Temple's Comet, and also that certain other meteors, which appear
every year in considerable numbers about the 10th of August,
followed the track of another comet called Tuttle's Comet. Then in
1872 came the display, mentioned in the last section, of meteors
which were evidently the debris of the vanished comet of Biela. The
inference from so many similar cases was irresistible that the
meteors must be fragments of destroyed or partially destroyed
comets. Several other cases of identity of orbits between meteors
and comets have been discovered.
It has been said that the August meteors appear every year. The
explanation of this is that they have, in the course of many ages,
been scattered around the whole circuit of their orbit, so that each
year, about the 10th of August, when the earth crosses their track,
some of the meteors are encountered. They are like an endless
railroad train travelling upon a circular track. The November meteors
also appear, in small numbers, every year, a fact indicating that
some of them, too, have been scattered all around their orbit,
although the great mass of them is still concentrated in an elongated
swarm, and a notable display can only occur when this swarm is at
the crossing simultaneously with the earth. These meteors were
eagerly awaited in 1899, when it was hoped that the splendid
displays of 1833 and 1866 might be repeated, but, unfortunately, in
the meantime the planets Jupiter and Saturn, by their disturbing
attractions, had so altered the position of the path of the meteors in
space that the principal swarm missed the connection. There are
many other periodical meteor showers, generally less brilliant than
those already mentioned, and some astronomers think that all of
them had their origin from comets.
It is not known that any meteor from any of these swarms has
ever reached the surface of the earth. The meteors appear to be so
small that they are entirely burnt up before they can get through the
atmosphere, which thus acts as a shield against these little missiles
from outer space. But there is another class of meteoric bodies,
variously known as meteorites, aërolites, uranoliths, or bolides,
which consists of larger masses, and these sometimes fall upon the
earth, after a fiery passage through the air. Specimens of them may
be seen in many museums. They are divided into two principal
classes, according to their composition: first, stony meteorites, which
are by far the most numerous; and, second, iron meteorites, which
consist of almost pure iron, generally alloyed with a little nickel. The
stony meteorites, which usually contain some compound of iron,
consist of a great variety of substances, including between twenty
and thirty different chemical elements. Although they resemble in
many ways minerals of volcanic origin on the earth, they also
possess certain characteristics by which they can be recognised even
when they have not been seen to fall.
When a meteorite passes through the air it makes a brilliant
display of light, and frequently bursts asunder, with a tremendous
noise, scattering its fragments about. The largest fragment of a
meteorite actually seen to fall, weighs about a quarter of a ton.
Upon striking the ground the meteorite sometimes penetrates to a
depth of several feet, and some have been picked up which were yet
hot on the surface, although very cold within. It is not known that
meteorites have any connection with comets, and their origin can
only be conjectured. Among the various suggestions that have been
made the following may be mentioned: (1) that they have been shot
out of the sun—particularly the iron meteorites; (2) that they were
cast into space by lunar volcanoes when the moon was still subject
to volcanic action; (3) that they are the products of explosion in the
stars. But some astronomers are disposed to think that they
originated in a similar manner to other members of the solar system,
although it is difficult, on this hypothesis, to account for their great
density. The opinion that the iron meteorites have come from the
sun, or some other star, is enforced by the fact that they contain
hydrogen, carbon, and helium, in forms suggesting that these gases
were absorbed while the bodies were immersed in a hot, dense
atmosphere.
PART IV.
The stars are divided into five principal types, according to their
spectra. These are:
I. White stars, having a bluish tinge, in which the spectrum is
characterised by broad dark bands, due apparently to an extensive
atmosphere of hydrogen, while there are but few lines indicating the
presence of metallic vapours. About half the stars whose spectra
have been studied belong to Type I.
II. Yellowish-white stars, resembling the sun in having their
spectra crossed with a great number of lines produced by metallic
vapours, while the hydrogen lines are less conspicuous. These are
often called solar stars, and they, too, are very numerous.
III. Orange and slightly reddish stars, whose spectra contain
mostly broad bands instead of narrow lines, the bands being
situated toward the blue end of the spectrum, whence the prevailing
colour, since the blue light is thus cut off. Only a few hundred of
these stars are known, but they include most of the well-known
variable stars.
IV. Small deep-red stars having dark bands absorbing the light of
the red end of the spectrum. Less than a hundred of these stars are
known.
V. Stars whose spectra are characterised by bright instead of dark
lines, although they also show dark bands. The bright lines indicate
that the atmospheric vapours producing them are at a higher
temperature than the body of the star. Stars of this type are
sometimes called Wolf-Rayet stars and they are few in number.
Various modifications of these main types exist, but we cannot
here enter into an account of them. In a general way, although there
are exceptions depending upon the precise nature of each spectrum,
the white stars are thought to be younger than the yellowish ones,
and the red stars older.
In speaking of the “size” of the stars we really mean their
luminosity, or the amount of light radiated from them. When a star is
said to be a thousand times greater than the sun, the meaning is
that the amount of light that it gives would, if both were viewed
from the same distance, be equal to a thousand times the amount
given by the sun. We have no direct knowledge of the actual size of
the stars as globes, because the most powerful telescope is unable
to reveal the real disk of a star. In comparing the luminosity of a star
with that of the sun its distance must be taken into account. Most of
the stars are so far away that we really know nothing of their
distances, but there are fifty or more which lie within a distance not
too great to enable us to obtain an approximate idea of what it is.
The nearest star in the northern sky is so far from being the
brightest that it can barely be seen with the naked eye. It must be
very much less luminous than the sun. On the other hand, some
very bright stars lie at a distance so immense that it can hardly be
estimated, and they must exceed the sun in luminosity hundreds and
even thousands of times.
The question of the distance of the stars has already been treated
in the section on Parallax. In employing our knowledge of star
distances for the purpose of comparing their luminosity with that of
the sun, we must first ascertain, as accurately as possible, the actual
amount of light that the star sends to the earth as compared with
the actual amount of light that the sun sends. The star Arcturus
gives to our eyes about one forty-billionth as much light as the sun
does. Knowing this, we must remember that the intensity of light
varies, like gravitation, inversely as the square of the distance. Thus,
if the sun were twice as far away as it is, the amount of its light
received on the earth would be reduced to one fourth, and if its
distance were increased three times, the amount would be reduced
to one ninth. If the sun were 200,000 times as far away, its light
would be reduced to one forty-billionth, or the same as that of
Arcturus. At this point the actual distance of Arcturus enters into the
calculation. If that distance were 200,000 times the sun's distance,
we should have to conclude that Arcturus was exactly equal to the
sun in luminosity, since the sun, if removed to the same distance,
would give us the same amount of light. But, in fact, we find that
the distance of Arcturus, instead of being 200,000 times that of the
sun, is about 10,000,000 times. In other words, it is fifty times as far
away as the sun would have to be in order that it should appear to
our eyes no brighter than Arcturus. From this it follows that the real
luminosity of Arcturus must be the square of 50, or 2500, times that
of the sun. In the same manner we find that Sirius, which to the eye
appears to be the brightest star in the sky (much brighter than
Arcturus because much nearer), is about thirty times as luminous as
the sun.
Many of the stars are changeable in brightness, and those in
which the changes occur to a notable extent, and periodically, are
known as variable stars. It is probable that all the stars, including
the sun, are variable to a slight degree. Among the most remarkable
variables are Mira, or Omicron Ceti, in the constellation Cetus, which
in the course of about 331 days rises from the ninth to the third
magnitude and then falls back again (the maxima of brightness are
irregular); and Algol, or Beta Persei, in the constellation Perseus,
which, in a period of 2 days, 20 hours, 49 minutes, changes from
the third to the second magnitude and back again. In the case of
Mira the cause of the changes is believed to lie in the star itself, and
they may be connected with its gradual extinction. The majority of
the variable stars belong to this class. As to Algol, the variability is
apparently due to a huge dark body circling close around the star
with great speed, and periodically producing partial eclipses of its
light. There are a few other stars with short periods of variability
which belong to the class of Algol.
When examined with telescopes many of the stars are found to be
double, triple, or multiple. Often this arises simply from the fact that
two or more happen to lie in nearly the same line of sight from the
earth, but in many other cases it is found that there is a real
connection, and that the stars concerned revolve, under the
influence of their mutual gravitation, round a common centre of
force. When two stars are thus connected they are called a binary.
The periods of revolution range from fifty to several hundred years.
Among the most celebrated binary stars are Alpha Centauri, in the
southern hemisphere, the nearest known star to the solar system,
whose components revolve in a period of about eighty years;
Gamma Virginis, in the constellation Virgo, period about one
hundred and seventy years; and Sirius, period about fifty-three
years. In the case of Sirius, one of the components, although
perhaps half as massive as its companion, is ten thousand times less
bright.
There is another class of binary stars, in which one of the
companions is invisible, its presence being indicated by the effects of
its gravitational pull upon the other. Algol may be regarded as an
example of this kind of stellar association. But there are stars of this
class, where the companion causes no eclipses, either because it is
not dark, or because it never passes over the other, as seen from the
earth, but where its existence is proved, in a very interesting way, by
the spectroscope. In these stars, called spectroscopic binaries, two
bright components are so close together that no telescope is able to
make them separately visible, but when their plane of revolution lies
nearly in our line of sight the lines in their combined spectrum are
seen periodically split asunder. To understand this, we must recall
the principles underlying spectroscopic analysis and add something
to what was said before on that subject.
Light consists of waves in the ether of different lengths and
making upon the eye different impressions of colour according to the
length of the waves. The longest waves are at the red end of the
spectrum and the shortest at the blue, or violet, end. But since they
all move onward with the same speed, it is clear that the short blue
waves must fall in quicker succession on the retina of the eye than
the long red waves. Now suppose that the source of light from which
the waves come is approaching very swiftly; it is easy to see that all
the waves will strike the eye with greater rapidity, and that the
whole spectrum will be shifted toward the blue, or short-wave, end.
The Fraunhofer lines will share in this shifting of position. Next
suppose that the source of the light is retreating from the eye. The
same effect will occur in a reversed sense, for now there will be a
general shift toward the red end of the spectrum. A sufficiently clear
illustration, by analogy, is furnished by the waves of sound. We know
that low-pitched sounds are produced by long waves, and high-
pitched ones by short waves; then if the source of the sound, such
as a locomotive whistle, rapidly approaches the ear the waves are
crowded together, or shifted as a whole toward the short end of the
gamut, whereupon the sound rises to a shrill scream. If, on the
contrary, the source of sound is retreating, the shift is in the other
direction, and the sound drops to a lower pitch.
This is precisely what happens in the spectrum of a star which is
either approaching or receding from the eye. If it is approaching, the
Fraunhofer lines are seen shifted out of their normal position toward
the blue, and if it is receding they are shifted toward the red. The
amount of shifting will depend upon the speed of the star's motion.
If that motion is across the line of sight there will be no shifting,
because then the source of light is neither approaching nor receding.
Now take the case of a binary star whose components are too close
to be separated by a telescope. If they happen to be revolving round
their common centre in a plane nearly coinciding with the line of
sight from the earth, one of them must be approaching the eye at
the same time that the other is receding from it, and the
consequence is that the spectral lines of the first will be shifted
toward the blue, while those of the second are shifted toward the
red. The colours of the two intermingled spectra blend into each
other too gradually to enable this effect to be detected by their
means, but the Fraunhofer lines are sharply defined, and in them the
shift is clearly seen; and since there is a simultaneous shifting in
opposite directions the lines appear split. But when the two stars are
in that part of their orbit where their common motion is across the
line of sight the lines close up again, because then there is no shift.
This phenomenon is beautifully exhibited by one of the first
spectroscopic binaries to be discovered, Beta Aurigæ. In 1889, Prof.
E. C. Pickering noticed that the spectral lines of this star appeared
split every second night, from which he inferred that it consisted of
two stars revolving round a common centre in a period of four days.
This spectroscopic method has been applied to determine the
speed with which certain single stars are approaching or receding
from the solar system. It has also served to show, what we have
before remarked, that the inner parts of Saturn's rings travel faster
than the outer parts. Moreover, it has been used in measuring the
rate of the sun's rotation on its axis, for it is plain that one edge of
the sun approaches us while the opposite edge is receding. Even the
effect of the rotation of Jupiter has been revealed in this way, and
the same method will probably settle the question whether Venus
rotates rapidly, or keeps the same face always toward the sun.
Not only do many stars revolve in orbits about near-by
companions, but all the stars, without exception, are independently
in motion. They appear to be travelling through space in many
different directions, each following its own chosen way without
regard to the others, and each moving at its own gait. These
movements of the stars are called proper motions. The direction of
the sun's proper motion is, roughly speaking, northward, and it
travels at the rate of twelve or fourteen miles per second, carrying
the earth and the other planets along with it. Some stars have a
much greater speed than the sun, and some a less speed. As we
have said, these motions are in many different directions, and no
attempt to discover any common law underlying them has been
entirely successful, although it has been found that in some parts of
the sky a certain number of stars appear to be travelling along
nearly parallel paths, like flocks of migrating birds. In recent years
some indications have been found of the possible existence of two
great general currents of movement, almost directly opposed to
each other, part of the stars following one current and part the other.
But no indication has been discovered of the existence of any
common centre of motion. Several relatively near-by stars appear to
be moving in the same direction as the sun. Stars that are closely
grouped together, like the cluster of the Pleiades, seem to share a
common motion of translation through space. We have already
remarked that when stars are found to be moving toward or away
from the sun, spectroscopic observation of the shifting of their lines
gives a means of calculating their velocity. In other cases, the
velocity across the line of sight can be calculated if we know the
distance of the stars concerned. One interesting result of the fact
that the earth goes along with the sun in its flight is that the orbit of
the earth cannot be a closed curve, but must have the form of a
spiral in space. In consequence of this we are continually advancing,
at the rate of at least 400,000,000 miles per year, toward the
northern quarter of the sky. The path pursued by the sun appears to
be straight, although it may, in fact, be a curve so large that we are
unable in the course of a lifetime, or many lifetimes, to detect its
departure from a direct line. At any rate we know that, as the earth
accompanies the sun, we are continually moving into new regions of
space.
It has been stated that many millions of stars are visible with
telescopes—perhaps a hundred millions, or even more. The great
majority of these are found in a broad irregular band, extending
entirely round the sky, and called the Milky Way, or the Galaxy. To
the naked eye the Milky Way appears as a softly shining baldric
encircling the heavens, but the telescope shows that it consists of
multitudes of faint stars, whose minuteness is probably mainly due
to the immensity of their distance, although it may be partly a result
of their relative lack of actual size, or luminosity. In many parts of
the Milky Way the stars appear so crowded that they present the
appearance of sparkling clouds. The photographs of these
aggregations of stars in the Milky Way, made by Barnard, are
marvellous beyond description. In the Milky Way, and sometimes
outside it, there exist globular star-clusters, in which the stars seem
so crowded toward the centre that it is impossible to separate them
with a telescope, and the effect is that of a glistering ball made up of
thousands of silvery particles, like a heap of microscopic
thermometer bulbs in the sunshine. A famous cluster of this kind is
found in the constellation Hercules.
The Milky Way evidently has the form of a vast wreath, made up
of many interlaced branches, some of which extend considerably
beyond its mean borders. Within, this starry wreath space is
relatively empty of stars, although some thousands do exist there, of
which the sun is one. We are at present situated not very far from
the centre of the opening within the ring or wreath, but the proper
motion of the sun is carrying us across this comparatively open
space, and in the course of time, if the direction of our motion does
not change, we shall arrive at a point not far from its northern
border. The Milky Way probably indicates the general plan on which
the visible universe is constructed, or what has been called the
architecture of the heavens, but we still know too little of this plan to
be able to say exactly what it is.
The number of stars in existence at any time varies to a slight
degree, for occasionally a star disappears, or a new one makes its
appearance. These, however, are rare phenomena, and new stars
usually disappear or fade away after a short time, for which reason
they are often called temporary stars. The greatest of these
phenomena ever beheld was Tycho Brahe's star, which suddenly
burst into view in the constellation Cassiopeia in 1572, and
disappeared after a couple of years, although at first it was the
brightest star in the heavens. Another temporary star, nearly as
brilliant, appeared in the constellation Perseus, in 1901, and this, as
it faded, gradually turned into a nebula, or a star surrounded by a
nebula. It is generally thought that outbursts of this kind are caused
by the collision of two or more massive bodies, which were invisible
before their disastrous encounter in space. The heat developed by
such a collision would be sufficient to vaporise them, and thus to
produce the appearance of a new blazing star. It is possible that
space contains an enormous number of great obscure bodies,—
extinguished suns, perhaps—which are moving in all directions as
rapidly as the visible stars.
2. The Nebulæ. These objects, which get their name from their
cloud-like appearance, are among the most puzzling phenomena of
the heavens, although they seem to suggest a means of explaining
the origin of stars. Many thousands of nebulæ are known, but there
are only two or three bright enough to be visible to the naked eye.
One of these is in the “sword” of the imaginary giant figure marking
the constellation Orion, and another is in the constellation
Andromeda. They look to the unaided eye like misty specks, and
require considerable attention to be seen at all. But in telescopes
their appearance is marvellous. The Orion nebula is a broad,
irregular cloud, with many brighter points, and a considerable
number of stars intermingled with it, while the Andromeda nebula
has a long spindle shape, with a brighter spot in the centre. It is
covered and surrounded with multitudes of faint stars. It was only
after astronomical photography had been perfected that the real
shapes of the nebulæ were clearly revealed. Thousands of nebulæ
have been discovered by photography, which are barely if at all
visible to the eye, even when aided by powerful telescopes. This
arises from the fact that the sensitive photographic plate
accumulates the impression that the light makes upon it, showing
more and more the longer it is exposed. Plates placed in the focus of
telescopes, arranged to utilise specially the “photographic rays,” are
often exposed for many hours on end in order to picture faint
nebulæ and faint stars, so that they reveal things that the eye,
which sees all it can see at a glance, is unable to perceive.
Nebulæ are generally divided into two classes—the “white”
nebulæ and the “green” nebulæ. The first, of which the Andromeda
nebula is a striking example, give a continuous spectrum without
dark lines, as if they consisted either of gas under high pressure, or
of something in a solid or liquid state. The second, conspicuously
represented by the Orion nebula, give a spectrum consisting of a few
bright lines, characteristic of such gases as hydrogen and helium,
together with other substances not yet recognised. But there is no
continuous spectrum like that shown by the white nebulæ, from
which it is inferred that the green nebulæ, at least, are wholly
gaseous in their constitution. The precise constitution of the white
nebulæ remains to be determined.
It is only in relatively recent years that the fact has become known
that the majority of nebulæ have a spiral form. There is almost
invariably a central condensed mass from which great spiral arms
wind away on all sides, giving to many of them the appearance of
spinning pin-wheels, flinging off streams of fire and sparks on all
sides. The spirals look as if they were gaseous, but along and in
them are arrayed many condensed knots, and frequently curving
rows of faint stars are seen apparently in continuation of the
nebulous spirals. The suggestion conveyed is that the stars have
been formed by condensation from the spirals. These nebulæ
generally give the spectra of the white class, but there are also
sometimes seen bright lines due to glowing gases. The Andromeda
nebula is sometimes described as spiral, but its aspect is rather that
of a great central mass surrounded with immense elliptical rings,
some of which have broken up and are condensing into separate
masses. The Orion nebula is a chaotic cloud, filled with partial
vacancies and ribbed with many curving, wave-like forms.
There are other nebulæ which have the form of elliptical rings,
occasionally with one or more stars near the centre. A famous
example of this kind is found in the constellation Lyra. Still others
have been compared in shape to the planet Saturn with its rings,
and some are altogether bizarre in form, occasionally looking like
glowing tresses floating among the stars.
The apparent association of nebulæ with stars led to the so-called
nebular hypothesis, according to which stars are formed, as already
suggested, by the condensation of nebulous matter. In the
celebrated form which Laplace gave to this hypothesis, it was
concerned specially with the origin of our solar system. He assumed
that the sun was once enormously expanded, in a nebulous state, or
surrounded with a nebulous cloud, and that as it contracted rings
were left off around the periphery of the vast rotating mass. These
rings subsequently breaking and condensing into globes, were
supposed to have given rise to the planets. It is still believed that
the sun and the other stars may have originated from the
condensation of nebulæ, but many objections have been found to
the form in which Laplace put his hypothesis, and the discovery of
the spiral nebulæ has led to other conjectures concerning the way in
which the transformation is brought about. But we have not here the
space to enter into this discussion, although it is of fascinating
interest.
A word more should be said about the use of photography in
astronomy. It is hardly going too far to aver that the photographic
plate has taken the place of the human retina in recording celestial
phenomena, especially among the stars and nebulæ. Not only are
the forms of such objects now exclusively recorded by photography,
but the spectra of all kinds of celestial objects—sun, stars, nebulæ,
etc.—are photographed and afterward studied at leisure. In this way
many of the most important discoveries of recent years have been
made, including those of variable stars and new stars. Photographic
charts of the heavens exist, and by comparing these with others
made later, changes which would escape the eye can be detected.
Comets are sometimes, and new asteroids almost invariably,
discovered by photography. The changes in the spectra of comets
and new stars are thus recorded with an accuracy that would be
otherwise unattainable. Photographs of the moon excel in accuracy
all that can be done by manual drawing, and while photographs of
the planets still fail to show many of the fine details visible with
telescopes, continual improvements are being made. Many of the
great telescopes now in use or in course of construction are
intended specially for photographic work.
3. The Constellations. The division of the stars into
constellations constitutes the uranography or the “geography of the
heavens.” The majority of the constellations are very ancient, and
their precise origin is unknown, but those which are invisible from
the northern hemisphere have all been named since the great
exploring expeditions to the south seas. There are more than sixty
constellations now generally recognised. Twelve of these belong to
the zodiac, and bear the same names as the zodiacal signs, although
the precession of the equinoxes has drifted them out of their original
relation to the signs. Many of the constellations are memorials of
prehistoric myths, and a large number are connected with the story
of the Argonautic expedition and with other famous Greek legends.
Thus the constellations form a pictorial scroll of legendary history
and mythology, and possess a deep interest independent of the
science of astronomy. For their history and for the legends
connected with them, the reader who desires a not too detailed
résumé, may consult Astronomy with the Naked Eye, and for
guidance in finding the constellations, Astronomy with an Opera-
glass, or Round the Year with the Stars. The quickest way to learn
the constellations is to engage the aid of some one who knows them
already, and can point them out in the sky. The next best way is to
use star charts, or a star-finder or planisphere.
A considerable number of the brighter and more important stars
are known by individual names, such as Sirius, Canopus, Achernar,
Arcturus, Vega, Rigel, Betelgeuse, Procyon, Spica, Aldebaran,
Regulus, Altair, and Fomalhaut. Astronomers usually designate the
principal stars of each constellation by the letters of the Greek
alphabet, α, β, γ, etc., the brightest star in the constellation bearing
the name of the first letter, the next brightest that of the second
letter, and so on.
The constellations are very irregular in outline, and their borders
are only fixed with sufficient definiteness to avoid the inclusion of
stars catalogued as belonging to one, within the limits of another. In
all cases the names come from some fancied resemblance of the
figures formed by the principal stars of the constellation to a man,
woman, animal, or other object. In only a few cases are these
resemblances very striking.
The most useful constellations for the beginner are those
surrounding the north celestial pole, and we give a little circular
chart showing their characteristic stars. The names of the months
running round the circle indicate the times of the year when these
constellations are to be seen on or near the meridian in the north.
Turn the chart so that the particular month is at the bottom, and
suppose yourself to be facing northward. The hour when the
observation is supposed to be made is, in every case, about 9 o'clock
in the evening, and the date is about the first of the month. The top
of the chart represents the sky a little below the zenith in the north,
and the bottom represents the horizon in the north.
Fig. 18. The North Circumpolar Stars.
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.
ebooknice.com