Skip to content

Commit 9733383

Browse files
committed
add week2
1 parent 2133881 commit 9733383

File tree

5 files changed

+419
-0
lines changed

5 files changed

+419
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Κάθε Πέμπτη 5-7 Κτήριο Γαληνός
2+
13
# Exercises and projects
24
https://www.w3resource.com/python-exercises/
35
https://knightlab.northwestern.edu/2014/06/05/five-mini-programming-projects-for-the-python-beginner/
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Basics review"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": []
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"# Exercise 1\n",
22+
"Given a number n, read n number of strings and output each string with its index"
23+
]
24+
},
25+
{
26+
"cell_type": "code",
27+
"execution_count": null,
28+
"metadata": {},
29+
"outputs": [],
30+
"source": []
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"# Write to Files!"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 18,
42+
"metadata": {},
43+
"outputs": [],
44+
"source": [
45+
"# open file\n",
46+
"file = open(\"week1.txt\", \"a\")"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": 20,
52+
"metadata": {},
53+
"outputs": [
54+
{
55+
"data": {
56+
"text/plain": [
57+
"4"
58+
]
59+
},
60+
"execution_count": 20,
61+
"metadata": {},
62+
"output_type": "execute_result"
63+
}
64+
],
65+
"source": [
66+
"file.write(\"test\") #write to file"
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": 21,
72+
"metadata": {},
73+
"outputs": [],
74+
"source": [
75+
"file.close() #always remember to close"
76+
]
77+
},
78+
{
79+
"cell_type": "code",
80+
"execution_count": 32,
81+
"metadata": {},
82+
"outputs": [
83+
{
84+
"name": "stdout",
85+
"output_type": "stream",
86+
"text": [
87+
"['0\\n', 'test\\n', 'test2\\n']\n"
88+
]
89+
}
90+
],
91+
"source": [
92+
"with open(\"./week1.txt\", 'r') as file: #try to use 'with' where possible\n",
93+
" print(file.readlines())\n",
94+
"file.close() "
95+
]
96+
},
97+
{
98+
"cell_type": "markdown",
99+
"metadata": {},
100+
"source": [
101+
"# Read From Files"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": null,
107+
"metadata": {},
108+
"outputs": [],
109+
"source": [
110+
"with open(\"./week1.txt\", 'r') as file: #try to use 'with' where possible\n",
111+
" for i in range(10):\n",
112+
" file.write(str(i)+'\\n')\n",
113+
"file.close() "
114+
]
115+
},
116+
{
117+
"cell_type": "markdown",
118+
"metadata": {},
119+
"source": [
120+
"# Exercise 2\n",
121+
"same as 1 but the input is given from a file called input.txt"
122+
]
123+
},
124+
{
125+
"cell_type": "code",
126+
"execution_count": null,
127+
"metadata": {},
128+
"outputs": [],
129+
"source": []
130+
},
131+
{
132+
"cell_type": "markdown",
133+
"metadata": {},
134+
"source": [
135+
"# Dice Rolling Simulator"
136+
]
137+
},
138+
{
139+
"cell_type": "markdown",
140+
"metadata": {},
141+
"source": [
142+
"### Enter list comprehension"
143+
]
144+
},
145+
{
146+
"cell_type": "code",
147+
"execution_count": 35,
148+
"metadata": {},
149+
"outputs": [
150+
{
151+
"name": "stdout",
152+
"output_type": "stream",
153+
"text": [
154+
"2 2\n"
155+
]
156+
},
157+
{
158+
"data": {
159+
"text/plain": [
160+
"[2, 2]"
161+
]
162+
},
163+
"execution_count": 35,
164+
"metadata": {},
165+
"output_type": "execute_result"
166+
}
167+
],
168+
"source": [
169+
"[int(char) for char in input().split(' ')]"
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": null,
175+
"metadata": {},
176+
"outputs": [],
177+
"source": []
178+
}
179+
],
180+
"metadata": {
181+
"kernelspec": {
182+
"display_name": "Python 3",
183+
"language": "python",
184+
"name": "python3"
185+
},
186+
"language_info": {
187+
"codemirror_mode": {
188+
"name": "ipython",
189+
"version": 3
190+
},
191+
"file_extension": ".py",
192+
"mimetype": "text/x-python",
193+
"name": "python",
194+
"nbconvert_exporter": "python",
195+
"pygments_lexer": "ipython3",
196+
"version": "3.7.0"
197+
}
198+
},
199+
"nbformat": 4,
200+
"nbformat_minor": 2
201+
}

week2/readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Week 2
2+
## Files and loops
3+
4+
### Dice rolling simulator problem
5+
https://knightlab.northwestern.edu/2014/06/05/five-mini-programming-projects-for-the-python-beginner/
6+
7+
### Files
8+
https://www.pythonforbeginners.com/cheatsheet/python-file-handling
9+
https://docs.python.org/3/tutorial/inputoutput.html?highlight=file%20write
10+
11+
### List Comprehensions
12+
https://www.pythonforbeginners.com/basics/list-comprehensions-in-python

0 commit comments

Comments
 (0)