background preloader

Language Tutorials

Facebook Twitter

PyQt4

PyInstaller. Instant Python. This is a minimal crash-course in the programming language Python. To learn more, take a look at the documentation at the Python web site, www.python.org; especially the tutorial. If you wonder why you should be interested, check out the comparison page where Python is compared to other languages. This introduction has been translated into several languages, among them Portuguese, Italian, Spanish, Russian, French, Lithuanian, Japanese, German and Greek, and is currently being translated into Norwegian, Polish, and Korean. Since this document still might undergo changes, these translations may not always be up to date. Note: To get the examples working properly, write the programs in a text file and then run that with the interpreter; do not try to run them directly in the interactive interpreter - not all of them will work.

(Please do not ask me for details on this! To begin with, think of Python as pseudo-code. X,y,z = 1,2,3 first, second = second, first a = b = 123 Simple, isn’t it? #! Home. Porta serial e Python. 7. Input and Output — Python v2.7.1 documentation. There are several ways to present the output of a program; data can be printed in a human-readable form, or written to a file for future use. This chapter will discuss some of the possibilities. 7.1. Fancier Output Formatting So far we’ve encountered two ways of writing values: expression statements and the print statement. Often you’ll want more control over the formatting of your output than simply printing space-separated values.

The string module contains a Template class which offers yet another way to substitute values into strings. One question remains, of course: how do you convert values to strings? The str() function is meant to return representations of values which are fairly human-readable, while repr() is meant to generate representations which can be read by the interpreter (or will force a SyntaxError if there is no equivalent syntax). Some examples: Here are two ways to write a table of squares and cubes: Basic usage of the str.format() method looks like this: '! 7.1.1. 7.2.