-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_exercise_page189.py
More file actions
63 lines (38 loc) · 1.29 KB
/
python_exercise_page189.py
File metadata and controls
63 lines (38 loc) · 1.29 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
57
58
59
60
61
62
63
# esercizio numero 10.1 pagina 189
from pathlib import Path
path = Path('python_txt/learning_python.txt')
contents = path.read_text()
print(contents)
#second part of the exercise
from pathlib import Path
path = Path('python_txt/learning_python.txt')
contents = path.read_text()
lines = contents.splitlines()
for line in lines:
print(line)
# esercizio numero 10.2
message = "In Python you can pass an arbitrary number of arguments"
print(message.replace('Python', 'c'))
message = "In Python you can use boolean algebra "
print(message.replace('Python', 'c'))
message = "In Python you can store keys in a dictionary "
print(message.replace('Python', 'c'))
message = "In Python you can access elements into a list "
print(message.replace('Python', 'c'))
#esercizio numero 10.3
from pathlib import Path
path = Path('python_txt/pi_digits.txt')
contents = path.read_text()
print(contents)
# second part of this exercise
from pathlib import Path
path = Path('python_txt/pi_digits.txt')
contents = path.read_text()
contents = contents.rstrip()
print(contents)
# third part of this exercise
from pathlib import Path
path = Path('python_txt/pi_digits.txt')
contents = path.read_text()
for line in contents.splitlines():
print(line)