From 157adb7490d2f6ad114b8c2e2ba790349afccf92 Mon Sep 17 00:00:00 2001 From: jamaurz Date: Wed, 2 Aug 2017 13:04:36 +0300 Subject: [PATCH 1/2] rename variables --- challenges/1.3.Input/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/challenges/1.3.Input/main.py b/challenges/1.3.Input/main.py index 3e53486..79eb58c 100644 --- a/challenges/1.3.Input/main.py +++ b/challenges/1.3.Input/main.py @@ -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 ### From 6f683fad8a1cc111dddcd76fff655ef2831c6577 Mon Sep 17 00:00:00 2001 From: jamaurz Date: Wed, 2 Aug 2017 13:10:07 +0300 Subject: [PATCH 2/2] 7. Loops challenges --- challenges/{7.1.Loops => 7.A.Loops}/lesson.md | 0 .../lesson_settings.py | 0 .../{7.1.Loops => 7.A.Loops}/lesson_tests.py | 0 challenges/{7.1.Loops => 7.A.Loops}/main.py | 0 challenges/7.B.Loops/lesson.md | 13 +++++++++ challenges/7.B.Loops/lesson_settings.py | 7 +++++ challenges/7.B.Loops/lesson_tests.py | 6 +++++ challenges/7.B.Loops/main.py | 9 +++++++ challenges/7.C.Loops/lesson.md | 27 +++++++++++++++++++ challenges/7.C.Loops/lesson_settings.py | 7 +++++ challenges/7.C.Loops/lesson_tests.py | 7 +++++ challenges/7.C.Loops/main.py | 6 +++++ 12 files changed, 82 insertions(+) rename challenges/{7.1.Loops => 7.A.Loops}/lesson.md (100%) rename challenges/{7.1.Loops => 7.A.Loops}/lesson_settings.py (100%) rename challenges/{7.1.Loops => 7.A.Loops}/lesson_tests.py (100%) rename challenges/{7.1.Loops => 7.A.Loops}/main.py (100%) create mode 100644 challenges/7.B.Loops/lesson.md create mode 100644 challenges/7.B.Loops/lesson_settings.py create mode 100644 challenges/7.B.Loops/lesson_tests.py create mode 100644 challenges/7.B.Loops/main.py create mode 100644 challenges/7.C.Loops/lesson.md create mode 100644 challenges/7.C.Loops/lesson_settings.py create mode 100644 challenges/7.C.Loops/lesson_tests.py create mode 100644 challenges/7.C.Loops/main.py diff --git a/challenges/7.1.Loops/lesson.md b/challenges/7.A.Loops/lesson.md similarity index 100% rename from challenges/7.1.Loops/lesson.md rename to challenges/7.A.Loops/lesson.md diff --git a/challenges/7.1.Loops/lesson_settings.py b/challenges/7.A.Loops/lesson_settings.py similarity index 100% rename from challenges/7.1.Loops/lesson_settings.py rename to challenges/7.A.Loops/lesson_settings.py diff --git a/challenges/7.1.Loops/lesson_tests.py b/challenges/7.A.Loops/lesson_tests.py similarity index 100% rename from challenges/7.1.Loops/lesson_tests.py rename to challenges/7.A.Loops/lesson_tests.py diff --git a/challenges/7.1.Loops/main.py b/challenges/7.A.Loops/main.py similarity index 100% rename from challenges/7.1.Loops/main.py rename to challenges/7.A.Loops/main.py diff --git a/challenges/7.B.Loops/lesson.md b/challenges/7.B.Loops/lesson.md new file mode 100644 index 0000000..6eb2b09 --- /dev/null +++ b/challenges/7.B.Loops/lesson.md @@ -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.** diff --git a/challenges/7.B.Loops/lesson_settings.py b/challenges/7.B.Loops/lesson_settings.py new file mode 100644 index 0000000..3ed57cf --- /dev/null +++ b/challenges/7.B.Loops/lesson_settings.py @@ -0,0 +1,7 @@ +{ + "lesson_title": "Loops", + "chapter_number": 7, + "lesson_number": 2, + "id":"597e1a1a634a36abfebcda38", + "repl": "" +} diff --git a/challenges/7.B.Loops/lesson_tests.py b/challenges/7.B.Loops/lesson_tests.py new file mode 100644 index 0000000..7e93a18 --- /dev/null +++ b/challenges/7.B.Loops/lesson_tests.py @@ -0,0 +1,6 @@ +import unittest +from main import * + +class LoopInfiniteTests(unittest.TestCase): + def test_main(self): + self.assertFalse(end) \ No newline at end of file diff --git a/challenges/7.B.Loops/main.py b/challenges/7.B.Loops/main.py new file mode 100644 index 0000000..0538c73 --- /dev/null +++ b/challenges/7.B.Loops/main.py @@ -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; + \ No newline at end of file diff --git a/challenges/7.C.Loops/lesson.md b/challenges/7.C.Loops/lesson.md new file mode 100644 index 0000000..e82f6df --- /dev/null +++ b/challenges/7.C.Loops/lesson.md @@ -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.** diff --git a/challenges/7.C.Loops/lesson_settings.py b/challenges/7.C.Loops/lesson_settings.py new file mode 100644 index 0000000..f6d8ee3 --- /dev/null +++ b/challenges/7.C.Loops/lesson_settings.py @@ -0,0 +1,7 @@ +{ + "lesson_title": "Loops", + "chapter_number": 7, + "lesson_number": 1, + "id":"597e1a1a634a36abfebcda38", + "repl": "" +} diff --git a/challenges/7.C.Loops/lesson_tests.py b/challenges/7.C.Loops/lesson_tests.py new file mode 100644 index 0000000..0a206ab --- /dev/null +++ b/challenges/7.C.Loops/lesson_tests.py @@ -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) diff --git a/challenges/7.C.Loops/main.py b/challenges/7.C.Loops/main.py new file mode 100644 index 0000000..e713df1 --- /dev/null +++ b/challenges/7.C.Loops/main.py @@ -0,0 +1,6 @@ +sum = 0 + +for i in : # Use range() + sum = sum # Calculate the sum + +print('The sum is', sum) \ No newline at end of file