Question

In: Computer Science

In Python Which statement has a syntax error? Assume variables x, y, z, and age have...

In Python

Which statement has a syntax error? Assume variables x, y, z, and age have already been defined.

a.

y = y

b.

x + y = z

c.

age = '32'

d.

print('Name, age')

e.

None of the above

Which statement does not print a newline character at the end?

a.

print('First part…')

b.

print('First part…\n')

c.

print('First part…', end='')

d.

print('First part…', end=”-\n”)

e.

None of the above

Which function converts a string to an integer?

a.

int()

b.

integer()

c.

string_to_int()

d.

convert(string, int)

e.

None of the above

Solutions

Expert Solution

Which statement has a syntax error? Assume variables x, y, z, and age have already been defined.
a.  
y = y
b.  
x + y = z
c.  
age = '32'
d.  
print('Name, age')
e.  
None of the above
Answer: b) x+y =z
explanation: as per the syntax rules of python, left side of equals operator must not be an expression
hence it raises syntax error


Which statement does not print a newline character at the end?
a.  
print('First part…')
b.  
print('First part…\n')
c.  
print('First part…', end='')
d.  
print('First part…', end=”-\n”)
e.  
None of the above
Answer:c)print('First part…', end='')
explanation: end ='', it changes end character '\n' to '', so it will not print a newline

Which function converts a string to an integer?
a.  
int()
b.  
integer()
c.string_to_int()
d.  
convert(string, int)
e.  
None of the above
Answer:a)int()
it converts string to integer// if string contains all numeric characters


Related Solutions

Python # Write a program that examines three variables—x, y, and z # and prints the...
Python # Write a program that examines three variables—x, y, and z # and prints the largest odd number among them. # If none of them are odd, it should print a message to that effect. n = input('Enter the 1st Integer x: ') x = int(n) n = input('Enter the 2nd Integer y: ') y = int(n) n = input('Enter the 3rd Integer z: ') z = int(n) if x % 2 == 0 and y % 2 ==...
In the python code below, describe the scope of the variables x, y, z and u....
In the python code below, describe the scope of the variables x, y, z and u. def my_func(x):         y = x - 2         return y z = 6 if z > 4:           u = my_func(6)          print(u)
Assume that X, Y, and Z are independent random variables and that each of the random...
Assume that X, Y, and Z are independent random variables and that each of the random variables have a mean of 1. Further, assume σX = 1, σY = 2, and σZ = 3. Find the mean and standard deviation of the following random variables: a. U = X + Y + Z b. R = (X + Y + Z)/3 c. T = 2·X + 5·Y d. What is the correlation between X and Y? e. What is the...
[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) Generate a data set with three variables (X, Y and Z). X and Y have...
1) Generate a data set with three variables (X, Y and Z). X and Y have 10 observations for each (N=10), and Z has 13 observations (N=13). Each observation should have two digits (such as “83” or “8.3”). 2) Draw a stem-and-leaf display for variable Z only and draw a box plot display for variable Z after specifying the 5 numbers (UEX, LEX, FU, FL, MD). 3) Calculate the mean and standard deviation for variable X 4) Calculate the mean...
Assume that the variables w, x, y, and z are stored in memory locations 16, 32,...
Assume that the variables w, x, y, and z are stored in memory locations 16, 32, 48, and 128 respectively. Translate the following algorithmic operations into MIPS language equivalents: [Assume $s1 is the base register, and $s1 contains the address of memory location 0]                                                                                                             if ((x – y) ³ w) then       set x to y else: set x to z endif
The joint density function for random variables X, Y, and Z is f(x, y, z)= Cxyz  if...
The joint density function for random variables X, Y, and Z is f(x, y, z)= Cxyz  if 0 ≤ x ≤ 1, 0 ≤ y ≤ 2, 0 ≤ z ≤ 2, and f(x, y, z) = 0 otherwise. (a) Find the value of the constant C. (b) Find P(X ≤ 1, Y ≤ 1, Z ≤ 1). (c) Find P(X + Y + Z ≤ 1).
Suppose x,y ∈ R and assume that x < y. Show that for all z ∈...
Suppose x,y ∈ R and assume that x < y. Show that for all z ∈ (x,y), there exists α ∈ (0,1) so that αx+(1−α)y = z. Now, also prove that a set X ⊆ R is convex if and only if the set X satisfies the property that for all x,y ∈ X, with x < y, for all z ∈ (x,y), z ∈ X.
Which of the following are correct for P(x,y,z)= xyz + x(yz)' + x'(y + z) +...
Which of the following are correct for P(x,y,z)= xyz + x(yz)' + x'(y + z) + (xyz)' ? 1) P(0, 0, 1) = 0 2) P(0, 1, 0) = 1 3) P(0, 0, 0) = 1 4) P(1, 1, 1) = 1 5) P(1, 0, 0) = 0
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT