-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists and Range.py
More file actions
41 lines (37 loc) · 890 Bytes
/
Lists and Range.py
File metadata and controls
41 lines (37 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## Lists and Range
## A list contains sequence of values in []
## Each value can be float, int, or string
## Each value in list is called an element
## List can contain:
## Nested lists
## Tuples
## Dictionaries
## And much more
##
## Mutable
##
## Elements in a list and dictionaries are mutable
## Elements in a tuple or string aren't mutable
##
## Range generated a specefied list of numbers
## Used with loops
print(list(range(11)))
print(list(range(5, 11)))
print(list(range(0, 22, 2)))
num = [2, 5, 3, 7, 4, 10]
print(type(num))
print(num)
num.sort()
print(num)
num.reverse()
print(num)
items = ["cars", "bike", "plane"]
print(items)
items.append(num)
print(items)
items[3].insert(2, ["hello"])
print(items)
print(items[0])
print(items[3])
print(items[3][2])
print(items[3][2][0])