Skip to content
This repository was archived by the owner on Jun 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions challenges/1.3.Input/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### Modify the code below ###

#Ask the user for their name!
Name = ''
name = ''

#Ask the user for their age!
Age = ''
age = ''

print(Name)
print(Age)
print(name)
print(age)

### Modify the code above ###
13 changes: 13 additions & 0 deletions challenges/7.B.Loops/lesson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## The Infinite loop

If a condition never becomes false, a loop will never end. Such a loop is called an infinite loop.

The syntax of a while loop is:

```
while True:
print('loop step')
```

**_Instructions_**
**Fix an infinite loop, the condition can become true.**
7 changes: 7 additions & 0 deletions challenges/7.B.Loops/lesson_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lesson_title": "Loops",
"chapter_number": 7,
"lesson_number": 2,
"id":"597e1a1a634a36abfebcda38",
"repl": ""
}
6 changes: 6 additions & 0 deletions challenges/7.B.Loops/lesson_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import unittest
from main import *

class LoopInfiniteTests(unittest.TestCase):
def test_main(self):
self.assertFalse(end)
9 changes: 9 additions & 0 deletions challenges/7.B.Loops/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
num = 1
end = False

while int(num) : # Modify the condition
num = input("Enter a number :")
print("You entered: ", num)
else :
end = True;

27 changes: 27 additions & 0 deletions challenges/7.C.Loops/lesson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## For

For loops iterate over a given sequence

```
lst = [2, 3, 5]
for i in lst:
print(i)
```

The function range() return an iterable object with behaves as if it is a list. The object is not a list, it returns the successive items of the desired sequence.

```
for i in range(9):
print(i)
```

It is possible to let the range start at another number, or to specify a different increment.

```
for i in range(0, 9, 3):
print(i)
```

**_Instructions_**
**Generate the sequence of numbers between 2 and 10 and specify an increment 3.**
**Calculate the sum of numbers of this sequence.**
7 changes: 7 additions & 0 deletions challenges/7.C.Loops/lesson_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lesson_title": "Loops",
"chapter_number": 7,
"lesson_number": 1,
"id":"597e1a1a634a36abfebcda38",
"repl": ""
}
7 changes: 7 additions & 0 deletions challenges/7.C.Loops/lesson_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unittest
from main import *

class LoopsTests(unittest.TestCase):
def test_main(self):
self.assertTrue(switch_end)
self.assertTrue(switch_loop)
6 changes: 6 additions & 0 deletions challenges/7.C.Loops/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sum = 0

for i in : # Use range()
sum = sum # Calculate the sum

print('The sum is', sum)