Created
April 25, 2017 16:57
-
-
Save Ethan-Arrowood/375275be0f6285a3062b2cf187f1c37c to your computer and use it in GitHub Desktop.
FCC-Python-Variable-Challenge created by Ethan.Arrowood - https://repl.it/HTLB/4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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) | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest # learn more: https://python.org/pypi/unittest | |
# Write your code below this line | |
myName = 'Ethan' | |
myAge = 18 | |
tenMore = myAge + 10 | |
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment