-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path6_moar_lists.py
More file actions
56 lines (38 loc) · 1.1 KB
/
6_moar_lists.py
File metadata and controls
56 lines (38 loc) · 1.1 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Basic stats
digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
print (digits)
print ("Min: " + str(min(digits)))
print ("Max: " + str(max(digits)))
print ("Sum: " + str(sum(digits)))
# lists combined with loops...
squares = [value**2 for value in range(1,11)]
print (squares)
# What about reanges and ways to select inside the list?
pokemon = ['Charmander', 'Squirtle', 'Bulbasaur', 'Pikachu']
# pokemon? seriosly?
# okay, lets do some ranges
# Select the first one
print (pokemon[:1])
# Select the last two
print (pokemon[2:])
# Select the middle one
print (pokemon[1:2])
# Loop the first ones...
for p in pokemon[:3] :
print (p)
# I want this pokemon set too...
commenter_pokemons = pokemon[:]
print ("My pokemons")
print (pokemon)
print ("Commenter pokemons")
commenter_pokemons.pop() # I dont like pikachu
print (commenter_pokemons)
# Can i create a list that doesnt change?
# Tuples!
dimensions = (200,500)
print (dimensions[0])
# I will get a nasty error if I try to change the value of [0]
# but I can assing a new value to the whole tuple
dimensions = (500,100)
print (dimensions[0])
# Just because we can...