70.1k views
1 vote
Assign testResult with 1 if either geneticMarkerA is 1 or geneticMarkerB is 1. If geneticMarkerA and geneticMarkerB are both 1, then assign testResult with 0. If geneticMarkerA and geneticMarkerB are both 0, then assign testResult with 0. Ex: If geneticMarkerA is 1 and geneticMarkerB is 0, then testResult is assigned with 1. If geneticMarkerA is 1 and geneticMarkerB is 1, then testResult is assigned with 0.

2 Answers

5 votes

You can achieve this using conditional statements in many programming languages. Below is an example using Python.

geneticMarkerA = 1

geneticMarkerB = 0

if geneticMarkerA == 1 or geneticMarkerB == 1:

testResult = 1

elif geneticMarkerA == 1 and geneticMarkerB == 1:

testResult = 0

else:

testResult = 0

print("testResult:", testResult)

In this example, geneticMarkerA and geneticMarkerB are assigned values, and the if statements check the conditions you specified. The variable testResult is assigned accordingly, and the result is printed.

User Kamila
by
8.0k points
6 votes

Answer:

Following python statement will give the assignment to testResult as specified:

if((geneticMarkerA == 1) or (geneticMarkerB ==1)):

testResult = 1

if((geneticMarkerA ==1) and (geneticMarkerB == 1)):

testResult = 0

if((geneticMarkerA == 0) and (geneticMarkerB == 0)):

testResult = 0

Step-by-step explanation:

In above statements or and and operator are used to check the conditions of set of values present in variable geneticMarkerA and geneticMarkerB.

Based on if the condition evaluate to true or false respective values to testResult varaible is assigned.

Following is sample run for above statements:

geneticMarkerA = 1

geneticMarkerB = 0

if((geneticMarkerA == 1) or (geneticMarkerB ==1)):

testResult = 1

if((geneticMarkerA ==1) and (geneticMarkerB == 1)):

testResult = 0

if((geneticMarkerA == 0) and (geneticMarkerB == 0)):

testResult = 0

print(testResult)

Output

1

User Saaj
by
7.4k points