Skip to content

Commit 44fb42d

Browse files
committed
update
Signed-off-by: Harmouch101 <mahmoudddharmouchhh@gmail.com>
1 parent a04a93f commit 44fb42d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Chapter_01: The Language Basics.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Don't give up. Difficult roads **often** lead to beautiful destinations.
6565
3.11 [Generators](#3.11)
6666
&nbsp;&nbsp;&nbsp;&nbsp;3.11.1 [Generator Function](#3.11.1)
6767
&nbsp;&nbsp;&nbsp;&nbsp;3.11.2 [Generator Expression](#3.11.2)
68-
&nbsp;&nbsp;&nbsp;&nbsp;3.11.3[Generator Exercices.](#3.11.3)
68+
&nbsp;&nbsp;&nbsp;&nbsp;3.11.3 [Generator Exercises.](#3.11.3)
6969
3.12 [Input](#3.12)
7070
3.13 [Exceptions](#3.13)
7171

@@ -2051,7 +2051,7 @@ StopIteration
20512051
128
20522052
```
20532053

2054-
### 3.11.3 Generator Exercices. <a name="3.11.3"></a><h5>[Go To TOC](#TOC).</h5>
2054+
### 3.11.3 Generator Exercises. <a name="3.11.3"></a><h5>[Go To TOC](#TOC).</h5>
20552055

20562056
```python
20572057
>>> def factorial():
@@ -2126,8 +2126,18 @@ StopIteration
21262126
Using the built-in `input()` method, you can get information from the user. It has an optional parameter `prompt` which prints a string on the screen.
21272127

21282128
```python
2129-
>>> n = eval(input("please give me a number and press <return> : ")) # eval converts the input to int.
2129+
>>> n = eval(input("please give me a number and press <return> : ")) # evaluate the input string as code..
21302130
please give me a number and press <return> : 10
2131+
>>> import os
2132+
>>> n = eval(input())
2133+
os.system('ls') # <----- you can insert a command as a string. So using eval is a security hole.
2134+
'Chapter_01: The Language Basics.md' Exercises LICENSE README.md
2135+
'Chapter_02: Functions, File IO, Generators.md' Images Projets
2136+
```
2137+
2138+
**Fun Exercises**
2139+
2140+
```python
21312141
>>> for i in range(n):
21322142
... print(' ' * ( n - i - 1 ) + '*' * ( 2 * i + 1 ))
21332143
...

0 commit comments

Comments
 (0)