repl.it
@claracavalcante/

tarefa2-29-10-2019

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import random 

def letraA(p, q):
	saida = []
	saida.append(p and q)
	saida.append(p or q)
	saida.append(q if p else (not q))
	saida.append(p == q)
	saida.append(p ^ q)
	return saida

def letraB(a, b):
	saida = []
	saida.append(not(b) if a else b)
	saida.append(not(b) and (a or (a and b)))
	return saida

def letraC(a, b, c):
	saida = []
	saida.append(a or (b and not(c)))
	saida.append((a or not(c))==(not(a or c)))
	return saida

def valores_auto():
	return {'p': bool(random.getrandbits(1)), 'q': bool(random.getrandbits(1)), 'a1': bool(random.getrandbits(1)), 'b1': bool(random.getrandbits(1)), 'a2': bool(random.getrandbits(1)), 'b2': bool(random.getrandbits(1)), 'c2': bool(random.getrandbits(1))}
	bool(random.getrandbits(1))

def valores_manual():
	return {'p': True, 'q': True, 'a1': True, 'b1': True, 'a2': True, 'b2': True, 'c2': True}


valores = valores_manual() #SE QUISER MANUAL, ALTERAR AQUI E COLOCAR OS VALORES NA FUNÇÃO

p = valores['p']
q = valores['q']
print("Letra A")
print("Entrada:\n p = "+ str(p)+"\n q = "+ str(q))
print("Saida: " + str(letraA(p, q)))

a = valores['a1']
b = valores['b1']
print("\n\nLetra B")
print("Entrada:\n a = "+ str(a)+"\n b = "+ str(b))
print("Saida: " + str(letraB(a, b)))

a = valores['a2']
b = valores['b2']
c = valores['c2']
print("\n\nLetra C")
print("Entrada:\n a = "+ str(a)+"\n b = "+ str(b)+"\n c = "+ str(c))
print("Saida: " + str(letraC(a, b, c)))