Skip to content

Instantly share code, notes, and snippets.

@cldershem
Forked from Ethan-Arrowood/instructions.py
Last active April 27, 2017 18:39
Show Gist options
  • Save cldershem/0649331a0127016a0be61dc5ebe89a74 to your computer and use it in GitHub Desktop.
Save cldershem/0649331a0127016a0be61dc5ebe89a74 to your computer and use it in GitHub Desktop.
FCC-Python-Variable-Challenge created by Ethan.Arrowood - https://repl.it/HTLB/5
"""
Title: Variables
Description/Explanation/Lesson:
Variables in Python are defined using the '=' (pronounced: 'is') operator.
Example: `my_age = 18`
Variables can contain values such as strings, numbers, lists, class
instances, and many more things!
Variables can also contain the values of operations & functions
Examples:
```
eight_squared = 8 ** 2
binary_from_decimal = bin(243)
```
Code Prompt/Challenge:
1. Define a variable 'my_name' and set it to your name as a string
2. Define a variable 'my_age' and set it to your age as a (whole) number
3. Define a variable 'ten_more' and set it to the your age + 10
Pre-defined Code:
Solution:
my_name = 'Ethan'
my_age = 18
ten_more = 18 + 10
Tests:
self.assertIsInstance(my_name, str)
self.assertIsInstance(my_age, int)
self.assertIsInstance(ten_more, int)
self.assertEqual(my_age + 10, ten_more)
"""
# Write your code below here!
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
tests.py
~~~~~~~~~~~~~~~~~
Module to test the user's code. Seperated from the lesson so the user need not
be overwhelmed by the tests and their boilerplate while writing their code.
"""
from lesson import (my_name, my_age, ten_more)
import unittest
class TestUserCode(unittest.TestCase):
def test_main(self):
self.assertIsInstance(my_name, str)
self.assertIsInstance(my_age, int)
self.assertIsInstance(ten_more, int)
self.assertEqual(my_age + 10, ten_more)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment