• Nov 18, 2022 •AustinLeath
0 likes • 14 views
# question3.py from itertools import product V='∀' 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('') # this is the logic for part A (p\/q\/r) /\ (p\/q\/~r) /\ (p\/~q\/r) /\ (p\/~q\/~r) /\ (~p\/q\/r) /\ (~p\/q\/~r) /\ (~p\/~q\/r) /\ (~p\/~q\/~r) def parta(p,q,r) : a=(p or q or r) and (p or q or not r) and (p or not q or r)and (p or not q or not r) b=(not p or q or r ) and (not p or q or not r) and (not p or not q or r) and (not p or not q or not r) c= a and b return c def partb(p,q,r) : a=(p or q and r) and (p or not q or not r) and (p or not q or not r)and (p or q or not r) b=(not p or q or r ) and (not p or q or not r) and (not p or not q or r) and (not p or not q or not r) c= a and b return c print("part A:") tt(parta,3) print("part B:") tt(partb,3)
• Sep 9, 2023 •AustinLeath
0 likes • 24 views
print("test")
• Nov 19, 2022 •CodeCatch
0 likes • 3 views
def max_n(lst, n = 1): return sorted(lst, reverse = True)[:n] max_n([1, 2, 3]) # [3] max_n([1, 2, 3], 2) # [3, 2]
• Jul 2, 2025 •AustinLeath
0 likes • 1 view
import calendar from datetime import datetime # Get the UTC timestamp a = calendar.timegm(datetime.utcnow().utctimetuple()) print(a)
• Feb 23, 2025 •hasnaoui1
0 likes • 7 views
print("hello world")
0 likes • 17 views
def sum_of_powers(end, power = 2, start = 1): return sum([(i) ** power for i in range(start, end + 1)]) sum_of_powers(10) # 385 sum_of_powers(10, 3) # 3025 sum_of_powers(10, 3, 5) # 2925