Write a program in Python to convert standard POS(product of sums) form to standard SOP(sum of products) form.
Assumptions: The input POS expression is standard. The variables in POS expression are continuous i.e. if expression contains variable A then it will have variables B, C respectively and each Sum term contains the alphabets in sorted order i.e. A + B + C (not like B+A+C).
Input : (A + B + C).(A + B + C').(A + B' + C).(A' + B + C) Output : A'BC + AB'C + ABC' + ABC Input : (A + B).(A' + B') Output : A'B + AB'
- First of all convert each sum term to its equivalent binary form. For example, if (A+B+C’) then take 0 for uncomplement variable(A, B) and take 1 for complement variable(C) so binary conversion is 011) and then finally equivalent to its decimal form(for ex: 001 = 1) and store in a list.
- Now for SOP form take all those terms which are not present in the list formed in step 1st and then convert each term to binary and hence change to POS form. For example –
Suppose 4 was not in the list then 5==> 101 (binary)
Now, replace 0 by complement variables(B)
replace 1 by uncomplement variables(A, C)
101 ==> AB’C
After each individual sum term use ‘+’
Below is the Python implementation of above approach:
Standard SOP form of (A+B+C).(A+B+C').(A+B'+C).(A'+B + C) ==> A'BC+AB'C+ABC'+ABC Standard SOP form of (A + B).(A'+B') ==> A'B+AB'
- Python | Program to convert String to a List
- Python program to convert a list to string
- Python program to convert floating to binary
- Python program to convert hex string to decimal
- Python | Program to convert a tuple to a string
- Python program to convert decimal to binary number
- Python program to convert any base to decimal by using int() method
- Python program to convert float decimal to Octal number
- Python Program to Convert any Positive Real Number to Binary string
- Python program to convert camel case string to snake case
- Python program to convert seconds into hours, minutes and seconds
- Python program to convert time from 12 hour to 24 hour format
- Python Program to convert List of Integer to List of String
- Python program to Convert a Matrix to Sparse Matrix
- Program to Convert Radian to Degree
- Program to Convert Km/hr to miles/hr and vice versa
- Python | Convert list to Python array
- Python code to convert SOP to POS
- Python | Convert a set into dictionary
- Convert JSON to CSV in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.