Question

In: Computer Science

X=5,Y=7,Z=10 A. if(X<Y): print "LESS" else: print "OTHER" B. if (x == 1): print "ONE" elif...

X=5,Y=7,Z=10

A. if(X<Y):

print "LESS"

else:

print "OTHER"

B.

if (x == 1): print "ONE"

elif (x == 2): print "TWO"

elif (x == 3): print "THREE"

elif (x == 4): print "FOUR"

elif (x == 5): print "FIVE"

elif (x == 6): print "SIX"

else: print "OTHER"

C.

if (X<Z):

print X

X = X + 1

D.

while (X<Z):

print X

X = X + 1

Q11. What is the final value of X in D

Q12. Is it legal to have an if with no else?

Q13. Is it legal to have an if with no elif?

Q14. Is the expression Y = X == 1 legal?

Q15. Is the expression IF (X<Z): legal?

Solutions

Expert Solution

Program:

X=5,Y=7,Z=10

A. if(X<Y):

print "LESS"

else:

print "OTHER"

B.

if (x == 1): print "ONE"

elif (x == 2): print "TWO"

elif (x == 3): print "THREE"

elif (x == 4): print "FOUR"

elif (x == 5): print "FIVE"

elif (x == 6): print "SIX"

else: print "OTHER"

C.

if (X<Z):

print X

X = X + 1

D.

while (X<Z):

print X

X = X + 1

Q11. What is the final value of X in D

Program:

import java.io.*;
class Segment
{
public static void main(String args[])throws IOException
{
int x=5,y=7,z=10;
if(x<y)
{
System.out.println("LESS");
}
if (x<z)
System.out.println("In C x= " +x);
x = x + 1;
while (x<z){
System.out.println("In D x= " +x);
x = x + 1;
}
}
}
Output:


  

Q11.

Answer: the final value of X in D is 9

Q12. Is it legal to have an if with no else?

Answer: legal

Q13. Is it legal to have an if with no elif?

Answer: legal

Q14. Is the expression Y = X == 1 legal?

Answer: It is not legal

Explanation:

Program:

import java.io.*;
class Segment
{
public static void main(String args[])throws IOException
{
int x,y;
y = x == 1;
System.out.println("In D y= " +y);

}
}

Output:

  


  Q15. Is the expression IF (X<Z): legal?

Answer: Legal


Related Solutions

What is the dominant color with these x and y values? x=7/15, y= 7/15 (z= 1/15...
What is the dominant color with these x and y values? x=7/15, y= 7/15 (z= 1/15 of course) Select one: a. Reddish green b. Greenish blue c. Violet d. Yellow
which would evaluate to false? ((x&&!y ||z) || !z&&x) a. x and y are false b....
which would evaluate to false? ((x&&!y ||z) || !z&&x) a. x and y are false b. x and z are false c. z is false d. x y z are true e. x is false
solve by determinants a.x+y+z=0 3x-y+2z=-1 2x+3y+3z=-5 b. x+2z=1 2x-3y=3 y+z=1 c. x+y+z=10 3x-y=0 3y-2z=-3 d. -8x+5z=-19...
solve by determinants a.x+y+z=0 3x-y+2z=-1 2x+3y+3z=-5 b. x+2z=1 2x-3y=3 y+z=1 c. x+y+z=10 3x-y=0 3y-2z=-3 d. -8x+5z=-19 -7x+5y=4 -2y+3z=3 e. -x+2y+z-5=0 3x-y-z+7=0 -2x+4y+2z-10=0 f. 1/x+1/y+1/z=12 4/x-3/y=0 2/y-1/z=3
Let F(x, y, z) = z tan^−1(y^2)i + z^3 ln(x^2 + 7)j + zk. Find the...
Let F(x, y, z) = z tan^−1(y^2)i + z^3 ln(x^2 + 7)j + zk. Find the flux of F across S, the part of the paraboloid x2 + y2 + z = 29 that lies above the plane z = 4 and is oriented upward.
Find ??, ?? and ?? of F(x, y, z) = tan(x+y) + tan(y+z) – 1
Find ??, ?? and ?? of F(x, y, z) = tan(x+y) + tan(y+z) – 1
Given: x y -5 1 -4 5 -3 4 -2 7 -1 10 0 8 1...
Given: x y -5 1 -4 5 -3 4 -2 7 -1 10 0 8 1 9 2 13 3 14 4 13 5 18 What are the confidence limits (alpha = 0.05) for the true mean value of Y when X = 3?
[x, y, and z are integer variables, which expressions are equivalent to each other?] a. (x==y...
[x, y, and z are integer variables, which expressions are equivalent to each other?] a. (x==y && x !=z) || (x!=y && x==z) b. (x==y || x==z) && (x!=y || x!=z) c. (x==y) != (x==z)
*(1)(a) Find a formula for the intersection of a cone {(x,y,z): x^2+y^2=z^2} with a plane {(x,y,z):...
*(1)(a) Find a formula for the intersection of a cone {(x,y,z): x^2+y^2=z^2} with a plane {(x,y,z): z=c}. (b) Find a formula for the intersection of a cone {(x,y,z): x^2+y^2=z^2} with a plane {(x,y,z): x=a}. (c) Find a formula for the intersection of a cone {(x,y,z): x^2+y^2=z^2} with a plane {(x,y,z): y=b}. *(2) Find a formula for the intersection of a cone {(x,y,z): x^2+y^2=z^2} with a plane {(x,y,z): z=kx+b} assuming both b and k are positive. (a) For what value of...
Rewrite the following statements to use only one if statement. if x < y if z < 10
Rewrite the following statements to use only one if statement.if x < yif z < 10w = x*y*zendend  
Let f(x, y) = x2y(2 − x + y2)5 − 4x2(1 + x + y)7 +...
Let f(x, y) = x2y(2 − x + y2)5 − 4x2(1 + x + y)7 + x3y2(1 − 3x − y)8. Find the coefficient of x5y3 in the expansion of f(x, y)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT