Question

In: Computer Science

Consider the following if statement, where doesSignificantWork​, ​makesBreakthrough​, and nobelPrizeCandidate​ are all boolean variables: if doesSignificantWork...

Consider the following if statement, where doesSignificantWork​, ​makesBreakthrough​, and nobelPrizeCandidate​ are all boolean variables:
if doesSignificantWork : if makesBreakthrough :
nobelPrizeCandidate = True else
nobelPrizeCandidate = False elif not doesSignificantWork:
nobelPrizeCandidate = False
(assume that ​doesSignificantWork and ​makesBreakthrough ​have been initialized, there is no error)
First, write a simpler ​if statement that is equivalent to this one. Then write a single assignment statement that does the same thing.
(Hint: Try to trace this piece of code with all possible initial values for makesBreakthrough and ​doesSignificantWork​. It helps you to understand the code and then you can simplify it and rewrite it).
CODE FOR PYTHON

Solutions

Expert Solution

The answer to this question is as follows:

doesSignificantWork=True
#initaializing the variables to check the if statements
makesBreakthrough=False
if doesSignificantWork : #doesSignificantWork is true then
if makesBreakthrough :#makesBreakthrough is true then
nobelPrizeCandidate = True#nobelPrizeCandidate is true
else:#otherwise
nobelPrizeCandidate = False#nobelPrizeCandidate is false
elif not doesSignificantWork:
nobelPrizeCandidate = False
print(nobelPrizeCandidate)


Related Solutions

Suppose we assume the logic has just 5 statement letters (i.e. Boolean variables): A, B, C,...
Suppose we assume the logic has just 5 statement letters (i.e. Boolean variables): A, B, C, D, and E. E1. Show a model that is a counterexample to (A ^ B) |= (B --> (not C))? E2. Expand the definition of entailment in the following two statements, explaining without using "entails" what they mean: a. P |= (Q v R) b. either (P |= Q) or (P |= R) or both Here, P, Q, and R are arbitrary formulas. E3....
Consider the following information on macroeconomic variables in a closed economy of Winterland (all figures are...
Consider the following information on macroeconomic variables in a closed economy of Winterland (all figures are in billion $): C=160 + 0.6 YD I=150 G=150 T=100 Identify the exogenous and endogenous variables in this model. Obtain the equilibrium level of GDP? Using the equilibrium GDP in b, obtain the equilibrium level of consumption spending. How much is the savinglevel at the equilibrium? Calculate the multiplier? If government purchase of goods and services (G) increase by $50 billion, how much the...
Consider a hypothetical economy characterized by the following equations (all variables as defined in class). Consumption:...
Consider a hypothetical economy characterized by the following equations (all variables as defined in class). Consumption: C = 700 + 0.95Y Investment: I=500− 30i Government spending: G=50 Money demand: L(i,Y )=0.75Y − 30i Money supply: Ms/P=400 (a) What is the equation of the IS curve? (b) What is the equation for the LM curve? (c) Solve for the equilibrium values of income (Y) and interest rates (i). (d) Assume that the government engages in expansionary fiscal policy by increasing expenditure...
Assume B is a Boolean Algebra. Prove the following statement using only the axioms for a...
Assume B is a Boolean Algebra. Prove the following statement using only the axioms for a Boolean Algebra properties of a Boolean Algebra. Uniqueness of 0: There is only one element of B that is an identity for + please include all the steps.
Consider the following data for two variables, and
Consider the following data for two variables,  and . 7 30 21 18 25   10 27 23 16 21   a. Develop an estimated regression equation for the data of the form . Comment on the adequacy of this equation for predicting . Enter negative value as negative number. The regression equation is     s= (to 3 decimals)   R2= % (to 1 decimal)   R Adjusted= % (to 1 decimal)   Analysis of Variance SOURCE DF SS(to 2...
Consider the following two estimated models (1) and (2), with all the variables already described below...
Consider the following two estimated models (1) and (2), with all the variables already described below ========================================= Dependent variable:    ---------------------------- log(wage)    (1)    (2) ----------------------------------------- educ    0.057*** 0.061***    (0.006) (0.006) tenure    0.018** 0.023*** (0.009) (0.009) black    0.070 (0.276) tenuresq -0.0003 -0.0004    (0.0005) (0.001) educ:black -0.031 (0.021) tenure:black 0.018** (0.008) Constant 5.924*** 5.829***    (0.088) (0.083) ----------------------------------------- Observations    935 935 R2 0.170 0.137 ========================================= Note: *p<0.1; **p<0.05; ***p<0.01 a. From model (1), what...
Write a program that inputs the values of three Boolean variables, a, b, and c, from...
Write a program that inputs the values of three Boolean variables, a, b, and c, from a “cin” operator (user gives the values be sure to prompt user for what they have to give!). Then the program determines the value of the conditions that follow as true or false. 1. !(a&&b&&c) && ! (a||b||c) 2. !(a||b)&&c Output should include the values of a,b,c ie 0 or 1 in the patterns that follow reflecting the Boolean logic being tested. Where “True”...
Write a Java program that defines two boolean variables a and b and shows that regardless...
Write a Java program that defines two boolean variables a and b and shows that regardless of the values of a and b, the expressions (a && (a || b)) and a are always the same.
1. Consider the following weighted averages of independent random variables X1, X2, X3, all with mean...
1. Consider the following weighted averages of independent random variables X1, X2, X3, all with mean u and variance σ^2 θ1 = 1/3(X1) + 1/3(X2) + 1/3(X3) θ2 = 1/4(X1) + 2/4(X2) + 1/4(X3) θ3 = 2/5(X1) + 2/5(X2) + 2/5(X3) a) Find E[θ1], E[θ2], E[θ3] b) Are θ1, θ2 and θ3 unbiased for u? Explain c) Find the variance for θ1, θ2 and θ3 d) If you had to use one of the above estimators, which would you pick?...
Simplify the following Boolean expressions to the minimum number of terms using the properties of Boolean...
Simplify the following Boolean expressions to the minimum number of terms using the properties of Boolean algebra (show your work and write the property you are applying). State if they cannot be simplified A. X’Y + XY B. (X + Y)(X + Y’) C. (A’ + B’) (A + B)’ D. ABC + A’B + A’BC’ E. XY + X(WZ + WZ’)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT