This shows you the differences between two versions of the page.
ii:labs:02:tasks:01 [2022/11/17 12:11] radu.mantu [01. [25p] Intro, datatypes and more] |
ii:labs:02:tasks:01 [2024/10/25 01:48] (current) radu.mantu |
||
---|---|---|---|
Line 325: | Line 325: | ||
>>> list(t) | >>> list(t) | ||
['pi', 3.1415, True] | ['pi', 3.1415, True] | ||
- | >>> list(t) + [ 'e', .5772, True ] | + | >>> list(t) + [ 'e', 2.7182, True ] |
- | ['pi', 3.1415, True, 'e', 0.5772, True] | + | ['pi', 3.1415, True, 'e', 2.7182, True] |
>>> # similarly, a tuple can be generated from a list | >>> # similarly, a tuple can be generated from a list | ||
- | >>> tuple(list(t) + [ 'e', .5772, True ]) | + | >>> tuple(list(t) + [ 'e', 2.7182, True ]) |
- | ('pi', 3.1415, True, 'e', 0.5772, True) | + | ('pi', 3.1415, True, 'e', 2.7182, True) |
>>> # tuples can be used as a shortcut to assign multiple values at once | >>> # tuples can be used as a shortcut to assign multiple values at once |