Loading...
More Python Posts
from itertools import productV='∀'E='∃'def tt(f,n) :xss=product((0,1),repeat=n)print('function:',f.__name__)for xs in xss : print(*xs,':',int(f(*xs)))print('')# p \/ (q /\ r) = (p \/ q) /\ (p \/ r)def prob1(p,q,r) :x=p or (q and r)y= (p or q) and (p or r)return x==ytt(prob1,3)# p/\(q\/r)=(p/\q)\/(p/\r)def prob2(p,q,r) :x=p and ( q or r )y=(p and q) or (p and r)return x==ytt(prob2,3)#~(p/\q)=(~p\/~q)def prob3(p,q) :x=not (p and q)y=(not p) or (not q)return x==ytt(prob3,2)#(~(p\/q))=((~p)/\~q)def prob4(p, q):x = not(p or q)y = not p and not qreturn x == ytt(prob4, 2)#(p/\(p=>q)=>q)def prob5(p,q):x= p and ( not p or q)return not x or qtt(prob5,2)# (p=>q)=((p\/q)=q)def prob6(p,q) :x = (not p or q)y=((p or q) == q)return x==ytt(prob6,2)#((p=>q)=(p\/q))=qdef prob7(p,q):if ((not p or q)==(p or q))==q:return 1tt(prob7,2)#(p=>q)=((p/\q)=p)def prob8(p,q):if (not p or q)==((p and q)==p):return 1tt(prob8,2)#((p=>q)=(p/\q))=pdef prob9(p,q):if ((not p or q)==(p and q))==p:return '1'tt(prob9,2)#(p=>q)/\(q=>r)=>(p=>r)def prob10(p,q,r) :x = not ((not p or q) and (not q or r)) or (not p or r)return xtt(prob10, 3)# (p = q) /\ (q => r) => (p => r)#answer 1def prob11(p,q,r) :x = not((p is q) and (not q or r)) or (not p or r)return xtt(prob11, 3)#(p=q)/\(q=>r)=>(p=>r)#answer 2def prob11(p,q,r):x=(p==q) and (not q or r)y=not p or rreturn not x or ytt(prob11,3)#((p=>q)/\(q=r))=>(p=>r)def prob12(p,q,r):x=(not p or q) and ( q==r )y=not p or rreturn not x or ytt(prob12,3)#(p=>q)=>((p/\r)=>(q/\r))def prob13(p,q,r):x=not p or qy=(not(p and r) or ( q and r))return not x or ytt(prob13,3)#Question#2----------------------------------------#(p=>q)=>r=p=>(q=>r)def prob14(p,q,r):x=(not(not p or q) or r)y=(not p or (not q or r))return x==ytt(prob14,3)def prob15(p, q):x = not(p and q)y = not p and not qreturn x == ytt(prob15, 2)def prob16(p, q):x = not(p or q)y = not p or not qreturn x == ytt(prob16, 2)def prob17(p):x = py = not preturn x == ytt(prob17, 1)
def print_pyramid_pattern(n):# outer loop to handle number of rows# n in this casefor i in range(0, n):# inner loop to handle number of columns# values changing acc. to outer loopfor j in range(0, i+1):# printing starsprint("* ",end="")# ending line after each rowprint("\r")print_pyramid_pattern(10)
import pandas as pdx = pd.read_excel(FILE_NAME)print(x)
def check_prop(fn, prop):return lambda obj: fn(obj[prop])check_age = check_prop(lambda x: x >= 18, 'age')user = {'name': 'Mark', 'age': 18}check_age(user) # True
print('hello, world')
def print_x_pattern(size):i,j = 0,size - 1while j >= 0 and i < size:initial_spaces = ' '*min(i,j)middle_spaces = ' '*(abs(i - j) - 1)final_spaces = ' '*(size - 1 - max(i,j))if j == i:print(initial_spaces + '*' + final_spaces)else:print(initial_spaces + '*' + middle_spaces + '*' + final_spaces)i += 1j -= 1print_x_pattern(7)