Did I do this right??

A forum for general discussion of the Python programming language.

Did I do this right??

Here is the question:
Create a script which yields the propositional logic for BITWISE AND (Conjunction), BITWISE OR (Disjunction), BITWISE XOR (EXCLUSIVE OR), Logical AND, Logical OR, Addition, Multiplication, and Bitwise NOT Inversion. THE OUTPUT SHOULD BE FORMATTED IN SIMILAR FORM AS THE RESULT ON PRIOR PAGE. (the format I know is right)

Here is my code:
Code: Select all
`print("BITWISE")print("x y AND")for x in [0,1]:    for y in [0,1]:        print(x,y,x&y)print("x y OR")for x in [0,1]:    for y in [0,1]:        print(x,y,x|y)        print("x y XOR")for x in [0,1]:    for y in [0,1]:        print(x,y,x^y)        print("LOGICAL")print("x y AND")for x in [0,1]:    for y in [0,1]:        print(x,y,x and y)print("x y OR")for x in [0,1]:    for y in [0,1]:        print(x,y,x or y)        print("x y Addition")for x in [0,1]:    for y in [0,1]:        print(x,y,x + y)print("x y Multiplication")for x in [0,1]:    for y in [0,1]:        print(x,y,x * y)print("x y NOT")for x in [0,1]:    for y in [0,1]:        print(x,y,x != y)`

Thanks
Last edited by ichabod801 on Thu Sep 22, 2016 9:50 pm, edited 1 time in total.
Reason: code tags, first post lock
doctterdre

Posts: 8
Joined: Thu Sep 22, 2016 9:44 pm

Re: Did I do this right??

Um, if you know the format is right all you need to check is the mathematical operators. Are you asking us to check if your program's math is right?
Due to the reasons discussed here we will be moving to python-forum.io on October 1st, 2016.
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
ichabod801

Posts: 688
Joined: Sat Feb 09, 2013 12:54 pm
Location: Outside Washington DC

Re: Did I do this right??

Im asking if I used the right operators
doctterdre

Posts: 8
Joined: Thu Sep 22, 2016 9:44 pm

Re: Did I do this right??

How do you think you can determine the correctness yourself?
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Did I do this right??

I think they are all right except maybe the last one, bitwise not. is bitwise not != or ~? thanks
doctterdre

Posts: 8
Joined: Thu Sep 22, 2016 9:44 pm