Skip to content

Commit b60537c

Browse files
committed
Add workshop presentation (13.nov)
0 parents  commit b60537c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4462
-0
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Workshop: Introduction to Python 3
2+
3+
## Presentation
4+
5+
Our presentation was built using remark, and you can open it [here](https://tiagodusilva.github.io/Workshop-Introduction-Python-3/).
6+
7+
## Wiki
8+
Link to our [wiki's Home page](../../wiki/Home)
9+
10+
## Contents
11+
1. [Interpreter](../../wiki/Interpreter)
12+
1. [Variables](../../wiki/Variables)
13+
1. [Data Types](../../wiki/Data-Types)
14+
1. [Flow Control](../../wiki/Flow-Control)
15+
1. [Data Structures](../../wiki/Data-Structures)
16+
1. [Iteration](../../wiki/Iteration)
17+
1. [Functions](../../wiki/Functions)
18+
1. [Comprehensions and Generators](../../wiki/Comprehensions-and-Generators)
19+
1. [Modules](../../wiki/Modules)
20+
21+
## Exercises and Solutions
22+
23+
1. [Exercises](../../wiki/Exercises)
24+
1. [Solutions](../../wiki/Solutions)
25+
26+
## Recommended IDEs
27+
- [Spyder/Anaconda](https://www.anaconda.com/distribution/): Installs python and various modules for you, recommended for an easier setup.
28+
- [VS Code](https://code.visualstudio.com/Download): Requires the manual installation of the [most recent version of Python 3](https://www.python.org/downloads/). Please refer to [Python in VS Code](https://code.visualstudio.com/docs/languages/python) for more detailed instructions. We recommend the Code Runner extension (present on the website listed above).
29+
- [Vim](https://www.vim.org/): [Vim8](https://vim8.org/) or [NeoVim](https://neovim.io/) prefered. Only use if you are familiar with Vim. Recommended extensions: coc, coc-python (node.js required for both).
30+
31+
## Other Resources
32+
33+
- Python Standard Library (Latest 3.x version released)
34+
- [Website](https://docs.python.org/3/library/index.html)
35+
- [Download as a file](https://docs.python.org/3/download.html)
36+
37+
## Authors
38+
39+
- João Costa (@joaocostaifg)
40+
- João Lucas (@joaolucasmartins)
41+
- Tiago Silva (@tiagodusilva)

assets/computer-society-logo.svg

Lines changed: 184 additions & 0 deletions
Loading

assets/nuieee-logo.png

39.8 KB
Loading

assets/slicing.png

82.3 KB
Loading

assets/variables-objects.png

69.6 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python3
2+
3+
alist = [1, 2, 3, 4, 5, 6, 7, 8]
4+
print("Our list:", alist)
5+
6+
# Remove 1 element
7+
del alist[1]
8+
print("Our list:", alist)
9+
10+
# Remove a slice
11+
del alist[0:3]
12+
print("Our list:", alist)
13+
14+
# Remove all elements (same as alist.clear())
15+
del alist[:]
16+
print("Our list:", alist)
17+

code/data structures/dict.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
3+
# Examples a dictionary declaration that associates names with age
4+
# Equivalent to ages = dict([[Carlos, 12], [Vilas, 19], [Tiago, 5]])
5+
# Or, since the keys are all simple strings, ages = dict(Carlos=12, Vilas=19, Tiago=5)
6+
ages = {"Carlos": 12, "Vilas": 19, "Tiago": 5}
7+
print("Our dict:", ages)
8+
9+
# Print a single element
10+
print("Tiago's age:", ages["Tiago"])
11+
12+
# We can add any key:value pair to dictionary at any time
13+
ages[432.5] = "oops"
14+
print("Our dict:", ages)
15+
16+
# The list() funtion will return a list of the keys in the dictionary in insertion order
17+
print("Our list:", list(ages))
18+
19+
# A dictionary is also an iterable (will be discussed in the iterable chapter)
20+
print("Carlos" in ages)
21+
22+
# The next commented line results in an order because we can't access non-existant keys
23+
# print(ages["123"])
24+
25+
# If we store a key that's already in use, the previous value of that key is dropped
26+
ages["Carlos"] = 11
27+
print("Our dict:", ages)
28+
29+
# We can use the del keyword with dictionaries
30+
del ages["Vilas"]
31+
print("Our dict:", ages)

code/data structures/lists.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python3
2+
3+
# Declare a list with the items 1, 2
4+
alist = [1, 2]
5+
print("Our list:", alist)
6+
7+
# Appends an element to the end of the list
8+
alist.append(5)
9+
print("Our list:", alist)
10+
11+
# Appends all the elements in an iterable to 'alist'
12+
anotherlist = [3, 4]
13+
alist.extend(anotherlist)
14+
print("Our list:", alist)
15+
16+
# Inserts an item, x, at a given position, i, in a list (list.insert(i,x))
17+
alist.insert(1, 9)
18+
print("Our List:", alist)
19+
20+
# Removes the first item from the list with value x (list.remove(x))
21+
alist.remove(9)
22+
print("Our List:", alist)
23+
24+
# Remove and return an item from a list at a given position, i
25+
# If no argument is given, remove and return the last element from the list
26+
alist.pop(1)
27+
print("Our List:", alist)
28+
29+
# Return the index of the first item with value x in the list
30+
# Can take an option start and/or end index (list.index(x[, start[, end]]))
31+
print("Index:", alist.index(1))
32+
33+
# Count the number of times an item, x, appears in the list
34+
print("Number of occurrences", alist.count(1))
35+
36+
# Reverses the items of the list, in place
37+
alist.reverse()
38+
print("Our list:", alist)
39+
40+
# blist is a pointer to alist
41+
blist = alist
42+
# blist is a shallow copy of alist
43+
blist = alist.copy()
44+
45+
# remove all items from a list (equivalent to del alist[:])
46+
print("Our list:", blist)
47+
blist.clear()
48+
print("Our list:", blist)
49+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python3
2+
3+
# Tuple packing
4+
atuple = (1, "hey", 123412.32)
5+
print("Our tuple", atuple)
6+
7+
# Sequence unpacking (paretheses are also optional here)
8+
(x, y, z) = atuple
9+
print("Our varibles:", x, y, z)

0 commit comments

Comments
 (0)