(Files begin with Int2Roman)
Solution 1: This is the round about solution which uses the position of the digit in the number and uses some crazy logic to convert from Integer to Roman!
Solution 2: This is a super condensed method to get the same result. Essentially, the logic is to do loop over the tupules/list, divide the number by each of the integers. If the quotient is > 1, then we have match. Multiply that with the roman number to get the actual value.
Solution 3: Same as 2. But uses Enums, Class methods and "yield". Good to understand Python!
(File : LogicGates.py)
This is an example from Interactive python which is particularly interesting since it helps us comprehend "OOP" Object oriented Python.
(File: ListPerformance.py)
This script tests creating lists using 4 different ways -
- Concatenate (Concatenate one list with another)
- Appending (using append function)
- List comprehension
- Using Range and List functions
We finally time each of the function using timeit module's Timer function. This runs each of the function 1000times before returning the average time taken.
(File: Stack.py)
This shows how to implement stacks in Python using Lists.
(File: StackExamples.py)
How to use some stacks to solve problems! This covers the following :
- Reverse a String using a Stack
- Check if the parantheses are balanced
- Check if the brackets (includes ( or [ or {), are balanced
- Convert a Decimal number to Binary
- Convert a Decimal number to Any other base number
(File: StackExamples-Convert2PostFix.py)
Example on how to convert Infix operations to Postfix format.