Diferència entre revisions de la pàgina «ASIX-M3-UF1-A2.2-Solucions Exercicis avaluar expressions lògiques»
De wikiserver
(Pàgina blanquejada) |
|||
(2 revisions intermèdies per 2 usuaris que no es mostren) | |||
Línia 1: | Línia 1: | ||
+ | == A2.2 Exercicis avaluar expressions lògiques == | ||
+ | Avalueu les següents condicions en funció dels valors corresponents de les variables | ||
+ | |||
+ | 1. ((y<x) or ((y>1) and (x>1))) | ||
+ | <pre> | ||
+ | a) x=1 y=1 | ||
+ | b) x=1 y=2 | ||
+ | c) x=2 y=1 | ||
+ | d) x=2 y=2 | ||
+ | e) x=0 y=0 | ||
+ | f) x=1 y=0 | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | a) x=1 y=1 False | ||
+ | b) x=1 y=2 False | ||
+ | c) x=2 y=1 True | ||
+ | d) x=2 y=2 True | ||
+ | e) x=0 y=0 False | ||
+ | f) x=1 y=0 True | ||
+ | </pre> | ||
+ | <!----> | ||
+ | 2. (((x>3) and (x<6)) or not((y>3) and (y<6))) <==> (3<x<6) or not (3<y<6) | ||
+ | <pre> | ||
+ | a) x=3 y=3 | ||
+ | b) x=3 y=4 | ||
+ | c) x=4 y=3 | ||
+ | d) x=4 y=4 | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | a) x=3 y=3 True | ||
+ | b) x=3 y=4 False | ||
+ | c) x=4 y=3 True | ||
+ | d) x=4 y=4 True | ||
+ | </pre> | ||
+ | <!----> | ||
+ | 3. (z>x and z>y or x>=y) | ||
+ | <pre> | ||
+ | a) x=1 y=1 z=1 | ||
+ | b) x=1 y=2 z=3 | ||
+ | c) x=1 y=3 z=2 | ||
+ | d) x=2 y=1 z=3 | ||
+ | e) x=2 y=3 z=1 | ||
+ | f) x=3 y=2 z=1 | ||
+ | g) x=3 y=1 z=2 | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | a) x=1 y=1 z=1 True | ||
+ | b) x=1 y=2 z=3 True | ||
+ | c) x=1 y=3 z=2 False | ||
+ | d) x=2 y=1 z=3 True | ||
+ | e) x=2 y=3 z=1 False | ||
+ | f) x=3 y=2 z=1 True | ||
+ | g) x=3 y=1 z=2 True | ||
+ | </pre> | ||
+ | <!----> |
Revisió de 16:17, 30 oct 2023
A2.2 Exercicis avaluar expressions lògiques
Avalueu les següents condicions en funció dels valors corresponents de les variables
1. ((y<x) or ((y>1) and (x>1)))
a) x=1 y=1 b) x=1 y=2 c) x=2 y=1 d) x=2 y=2 e) x=0 y=0 f) x=1 y=0
a) x=1 y=1 False b) x=1 y=2 False c) x=2 y=1 True d) x=2 y=2 True e) x=0 y=0 False f) x=1 y=0 True
2. (((x>3) and (x<6)) or not((y>3) and (y<6))) <==> (3<x<6) or not (3<y<6)
a) x=3 y=3 b) x=3 y=4 c) x=4 y=3 d) x=4 y=4
a) x=3 y=3 True b) x=3 y=4 False c) x=4 y=3 True d) x=4 y=4 True
3. (z>x and z>y or x>=y)
a) x=1 y=1 z=1 b) x=1 y=2 z=3 c) x=1 y=3 z=2 d) x=2 y=1 z=3 e) x=2 y=3 z=1 f) x=3 y=2 z=1 g) x=3 y=1 z=2
a) x=1 y=1 z=1 True b) x=1 y=2 z=3 True c) x=1 y=3 z=2 False d) x=2 y=1 z=3 True e) x=2 y=3 z=1 False f) x=3 y=2 z=1 True g) x=3 y=1 z=2 True