Python-program-to-convert-pos-to-sop

In this article, we will learn about the solution to the problem statement given below.

Problem statement − We are given pos form we need to convert it into its equivalent sop form

The conversion can be done by first counting the number of alphabets in the pos form and then calculating all the max and the minterms.

Now let’s observe the concept in the implementation below−

Example

# Python code to convert standard POS form
# to standard SOP form
# to calculate number of variables
def count_no_alphabets(POS):
   i = 0
   no_var = 0
   # total no. of alphabets before will be equal to alphabets before first '.' character
   while (POS[i]!='.'):
      # character is a alphabet or not
      if (POS[i].isalpha()):
         no_var+= 1
      i+= 1
   return no_var
# maximum terms in an integer
def Cal_Max_terms(Max_terms, POS):
   a = ""
   i = 0
   while (i " + SOP_expr)
# Driver code
if __name__=="__main__":
   main()

Output

Standard SOP form of (A'+B'+C).(A+B+C').(A+B'+C).(A'+B+C) ==>
A'B'C'+A'BC+AB'C+ABC

All the variables are declared in the local scope and their references are seen in the figure above.

Conclusion

In this article, we have learned about how we can convert pos to sop form

Updated on: 2019-12-24T05:55:35+05:30

287 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements