Skip to content

Instantly share code, notes, and snippets.

@Ethan-Arrowood
Created April 25, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Ethan-Arrowood/c9b709c8a65f5c3d7b7c9f8af0889d5b to your computer and use it in GitHub Desktop.
Save Ethan-Arrowood/c9b709c8a65f5c3d7b7c9f8af0889d5b 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 '=' operator. For example: myAge = 18
Variables can contain Strings, Numbers, Lists, Class Instances, and many more things!
Variables can also contain operations & methods i.e. eightSquared = 8 ** 2
Or, binaryFromDecimal = bin(243)
Code Prompt/Challenge:
1. Define a variable 'myName' and set it to your name as a String
2. Define a variable 'myAge' and set it to your age as a Number
3. Define a variable 'tenMore' and set it to the your age + 10
Pre-defined Code:
Solution:
myName = 'Ethan'
myAge = 18
tenMore = 18 + 10
Tests:
self.assertIsInstance(myName, str)
self.assertIsInstance(myAge, int)
self.assertIsInstance(tenMore, int)
self.assertEqual(myAge + 10, tenMore)
'''
import unittest # learn more: https://python.org/pypi/unittest
# Write your code below this line
# Write your code above this line
# -----------------------------
# Unit Tests - DO NOT EDIT
class TestCode(unittest.TestCase):
def test_main(self):
self.assertIsInstance(myName, str)
self.assertIsInstance(myAge, int)
self.assertIsInstance(tenMore, int)
self.assertEqual(myAge + 10, tenMore)
if __name__ == '__main__':
unittest.main()
@cldershem
Copy link

I have made a fork of this which updates the style to be inline with PEP 8 along with a few other minor changes. I also took the opportunity to experiment with the format so that the user wouldn't need to see the tests. Because the lesson dictates the name of the variables, one can import them into the tests so that there is less chance for confusion or errors during such an early lesson. I tested this out and it appeared to work the same in repl.it.

Here is a link to my fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment