Your Turn

This book is the introduction to Elixir for experienced programmers, completely updated for Elixir 1.6 and beyond. Explore functional programming without the academic overtones (tell me about monads just one more time). Create concurrent applications, butget them right without all the locking and consistency headaches. Meet Elix

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Printing Information

Practical Programming, Third Edition — by Paul Gries, Jennifer Campbell, Jason Montojo (41 / 161)

👈 Creating a Multiline String | TOC | Getting Information from the Keyb oard 👉

In Writing and Running a Program, built-in function print was used to print values to the screen. We will use print to print messages to the users of our program. Those messages may include the values that expressions produce and the values that the variables refer to. Here are two examples of printing:

Function print doesn’t allow any styling of the output: no colors, no italics, no boldface. All output is plain text.

The first function call does what you would expect from the numeric examples we have seen previously, but the second does something slightly different from previous string examples: it strips off the quotes around the string and shows us the string in a human-readable form, rather than its character representation. This example makes the difference between the two even clearer:

And the following example shows that when Python prints a string, any escape sequences are converted to a form that humans expect:

The previous example shows how the tab character \t can be used to lay values out in columns.

In Creating a Multiline String, we saw that \n indicates a new line in multiline strings. When a multiline string is printed, those \n sequences are displayed as new lines:

Function print takes a comma-separated list of values and prints the values with a single space between them…

Add a comment

Related posts:

Rejection is Your Path to Writing Success

How new writers can use rejection to achieve writing success. Do you need to write every day? What's more important, publishing quality or quantity?

Success in Breaking Free and Moving on from Problematic Habits

Unhelpful or self-limiting habits can be quite difficult to shake, break, leave and move on from yet there are answers in our psychology that can prove to be the key to needed progress or desired…

Controle e Descontrole

Eu sempre desconfiei do que é absoluto. Quem me dera fosse por valores científicos de questionar autoridades ou, até, pela própria defesa do indefinido. Na verdade é bem mais simples: cada vez mais…