Python notes
From Reboil
This page contains notes for coding in the Python scripting language.
Stats
Definitions
- list
- an ordered and changeable collection of data objects. Allows duplicate members. Similar to a tuple, set, or dictionary.[2]
- tuple
- a collection which is ordered and unchangeable. Allows duplicate members.[2]
Examples
Control
Start python3
.
$ python3
Exit python3
.
>>> exit()
Lists
Create a list.
>>> a = [2,3] >>> a [2,3]
Append a list with append()
.
>>> a.append(5) >>> a [2, 3, 5]
Remove the second element with pop()
.
>>> a [2, 3, 5] >>> a.pop(1) >>> a [2, 5]
Arrays
Scripts
Shebang pattern.
#!/usr/bin/env python
History
See also
External links
References
- ↑ As of Python 3.7.
- ↑ 2.0 2.1 2.2 2.3 “Python Lists”. (n.d.). w3schools.com. Accessed 2023-08-29.
- ↑ Set items are unchangeable, but you can remove and/or add items whenever you like.
Foonotes