Difference between revisions of "W1040 Printing and String Interpolation"

From Coder Merlin
Line 15: Line 15:
In its most basic form, the ''print'' function takes a single argument.  It's able to print integers, floating points, Booleans, and strings.
In its most basic form, the ''print'' function takes a single argument.  It's able to print integers, floating points, Booleans, and strings.
<syntaxhighlight lang="swift">
<syntaxhighlight lang="swift">
print(12)    // An Int
print(13.0)  // A Double
print(true)  // A Boolean
print("Water supply") // A String
</syntaxhighlight>
</syntaxhighlight>
== Key Concepts ==
== Key Concepts ==
== Exercises ==
== Exercises ==
== References ==
== References ==
* [https://en.wikipedia.org/wiki/Teleprinter Teleprinter] (Wikipedia)
* [https://en.wikipedia.org/wiki/Teleprinter Teleprinter] (Wikipedia)

Revision as of 21:07, 28 October 2019

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Teletype

Prerequisites[edit]

Background[edit]

A teletype machine (or teleprinter) is an electromechanical device which can be used to send and received typed messages over a distance. It was one of the first devices which enabled the layman, not trained in Morse Code, to communicate easily with another.

In addition to processing commands to print printable characters the teletype processed non-printable characters. The most common of these are:

TAB
A control character (ASCII code 0x09) used to move a device's position to the next horizontal tab stop.
LINE FEED
A control character (ASCII code 0x0A) used to move a device's position to the next line. Abbreviated as LF.
CARRIAGE RETURN
A control character (ASCII code 0x0D) used to reset a device's position to the beginning of a line of text. Abbreviated as CR.

Introduction[edit]

The print function is one of the most basic functions available and is also one of the most useful. It provides us with the ability to easily output data from our program, most often to the console. As such, it is invaluable for both a completed programming and for assisting us to debug a program during development.

Basic Usage[edit]

In its most basic form, the print function takes a single argument. It's able to print integers, floating points, Booleans, and strings.

print(12)    // An Int
print(13.0)  // A Double
print(true)  // A Boolean
print("Water supply") // A String

Key Concepts[edit]

Exercises[edit]

References[edit]