Skip to content

Commit 8829d03

Browse files
Merge pull request freeCodeCamp#20 from vladdoster/1.3_input
Completed and tested challenge 1.3 on input.
2 parents 69e6467 + 66c6ef4 commit 8829d03

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

challenges/1.3.Input/lesson.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Python Input
2+
3+
In Python 3, to get user input, use the input function and pass a string in as a parameter.
4+
You can assign this function to a variable in order to save input.
5+
- https://docs.python.org/3/library/functions.html#input
6+
7+
The input() function can take numbers and words as valid answers. All input is saved as a string regardless if they are numbers!
8+
In the example below, the input is saved to the 'school' and 'grade' variables they can be used later!
9+
10+
```
11+
>>> school = input('What school do you go to?')
12+
What school do you go to? Harvard
13+
>>> grade = input('What grade are you in?')
14+
What grade are you in? 4th
15+
>>> print (school)
16+
Harvard
17+
>>> print(grade)
18+
4th
19+
>>>
20+
```
21+
22+
23+
**_Instructions:_**
24+
**Prompt the user for their name and age. Print them out to console!**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### Modify the code below ###
2+
3+
#Ask the user for their name!
4+
Name = ''
5+
6+
#Ask the user for their age!
7+
Age = ''
8+
9+
print(Name)
10+
print(Age)
11+
12+
### Modify the code above ###
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"lesson_title": "Input Edit",
3+
"chapter_number": 1,
4+
"lesson_number": 3,
5+
"id":"592f1cc969cf862d8a7bb7f2",
6+
"repl": ""
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
import lesson_code
3+
4+
class InputTests(unittest.TestCase):
5+
def test_main(self):
6+
name = lesson_code.Name
7+
age = lesson_code.Age
8+
9+
self.assertIsInstance(name, str)
10+
self.assertIsInstance(age, str)
11+
# To run the tests from the console:
12+
# Make sure that you are in the '1.3.Addition' directory
13+
# python3 -m unittest lesson_tests

0 commit comments

Comments
 (0)