Premium Partner

asdf

asdf program

asdf program


Kartei Details

Karten 27
Sprache Deutsch
Kategorie Übrige
Stufe Universität
Erstellt / Aktualisiert 02.12.2014 / 03.12.2014
Lizenzierung Keine Angabe
Weblink
https://card2brain.ch/box/asdf11
Einbinden
<iframe src="https://card2brain.ch/box/asdf11/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>

Comments in Python starts with _, and extend to the end of the physical line.

hash character #

Complex numbers are supported; imaginary numbers are written with a suffix of (1) or (2). Complex numbers with a nonzero real component are written as (3), or can be created with (4) function.

(1) j

(2) J

(3) (real + imagj)

(4) complex(real, imag)

Complex numbers are always represented as two floating point numbers, the real and imaginary part. To extract these parts from a complex number z use (1) and (2).

(1) z.real

(2) z.imag

In interactive mode, the last printed expression is assigned to the variable (1). This means that when you are using Python as a desk calculator, it is somewhat easier to continue calculation.

(1) _

Strings literals can span multiple lines in several ways. Continuation lines can be used with (1) as the last character on the line indicating that the next line is a logical continuation of the line.

Or, strings can be surrounded (2) or (3). End of lines do not need to be escaped when using (2), (3), but they will be included in the string.

(1) a backslash

(2) in a pair of matching triple quotes: """

(3) '''

Strings can be concantenated (glued together) with (1), and repead with (2)

(1) the + operator

(2) *

word = 'Help' + 'A'

The line above could also have been written (1). This only works with two literals, not with arbitrary string expressions.

(1) word = 'Help' 'A'

Strings can be subscripted (indexed). The first character of a string has subscription (index) (1). Substrings can be specified with the slice notation: tow indices separated by (2)

(1) 0

(2) a colon