This file contains hidden or 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 yaml | |
| with open('persons.yaml', 'r') as f: | |
| my_dict = yaml.safe_load(f) | |
| for distro in my_dict: | |
| print(distro['gender']) |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <root> | |
| <persons> | |
| <element> | |
| <gender>male</gender> |
This file contains hidden or 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
| { | |
| "persons": [ | |
| { | |
| "name": "Jeff Bezos", | |
| "gender": "male" |
This file contains hidden or 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
| persons: | |
| - name: Jeff Bezos | |
| gender: male | |
| - name: Elon Musk | |
| gender: male |
This file contains hidden or 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 # importing standard unittest module from python library | |
| class TddPython(unittest.TestCase): # our class that would contain multiple test cases | |
| def test_calc_subtract_method(self): # test method | |
| calc = Calculator() # initiliate the Calculator |
This file contains hidden or 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
| class Calculator(object): | |
| def subtract(self, x, y): | |
| pass | |
| test_calc.py | |
| import unittest # importing standard unittest module from python library |
This file contains hidden or 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
| def fib1(n): # print Fibonacci series up to n | |
| x, y = 0, 1 | |
| while x < n: | |
| print(x, end=' ') | |
| x, y = y, x+y |
This file contains hidden or 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 fibonacci # import our module and all its functions (hint: there is only one) | |
| fibonacci.fib1(10) |
This file contains hidden or 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
| def fib1(n): # print Fibonacci series up to n | |
| x, y = 0, 1 | |
| while x < n: | |
| print(x, end=' ') | |
| x, y = y, x+y |
This file contains hidden or 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
| from fibonacci import fib2 # only import fib2 function | |
| print(fib2(10)) |