Question

In: Computer Science

23. Given a = 5, b = 4, c = 2, evaluate the following: a) a//c...

23. Given a = 5, b = 4, c = 2, evaluate the following:

a) a//c

b) a % b

c) b **c

d) b *= c

27. Given the following

var_1 = 2.0

var_2 = "apple"

var_3 = 'orange'

var_4 = 4

Predict the output of the following statements or indicate that there would be an error.

a) print (var_1)

b) print (var_2)

c) print ("var_3")

d) print (var_1 / var_4)

e) print (var_4 + var_3)

f) print (var_2 + var_3)

Solutions

Expert Solution

23. Given a = 5, b = 4, c = 2
(a)
a//c - Floor division or Integer division which returns the integer without any decimal
5//2 = 2

(b) a % b - Returns the remainder when a is divided by b
5%4 = 1

(c) b **c - Returns the result when b is raised to the power of c
4**2 = 4^2 = 16

(d) b *= c - Returns the result when b is multiplied by c and the result is stored back in b
b= b*c = 4*2 = 8

27. Given the following

var_1 = 2.0
var_2 = "apple"
var_3 = 'orange'
var_4 = 4

(a) print (var_1) - prints the value stored in variable var_1 i.e 2.0
2.0

(b) print (var_2) - prints the value stored in variable var_2 i.e "apple"
apple

(c) print ("var_3") - print the string "var_3"
var_3

(d) print (var_1 / var_4) - performs floating-point divison and prints the result obtained when var_1 is divided by var_4 i.e 2.0/4 = 0.5
0.5

(e) print (var_4 + var_3) - generates type error since there is no "+" operator specified for operand types "int" and "str"
TypeError: unsupported operand type(s) for +: 'int' and 'str'

(f) print (var_2 + var_3) - performs string concatenation of var_2 and var_3 and prints the result of this concatenation i.e "apple"+'orange' = appleorange
appleorange


Related Solutions

1. Evaluate: (a+b)/(c-d) + 9/(a+d) when a=5, b=3, c=8, d=4 a. 6 b. 3 c. 15/2...
1. Evaluate: (a+b)/(c-d) + 9/(a+d) when a=5, b=3, c=8, d=4 a. 6 b. 3 c. 15/2 d. 17/13 2. Solve for x: 5(x+3) = 35 a. 2 b. 7 c. 4 d. -4 3. Acid rain occurs primarily as a result of a. operating a nuclear power plant b. burning coal or oil containing sulfur c. by-products created by operating an oil refinery d. the use of Freon and other refrigerants 4. The "ozone holes" at the polar region arise...
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5]...
A = [4, 5, 9] B = [-4, 5, -7] C = [2, -7, -8, 5] D = [1, -9, 5, -3] E = [3, 3, -1] Uz = 1/|z| ^z d(X,Y) = (Rθ) d = diameter R = Radius θ = Theta Find a. Uc b. d (D, C) c. Let P = B + 3E, UP = d. A x B e. 3B x E f. C x D
Given the data below for the reaction, 2 A + 2 B + 4 C =>...
Given the data below for the reaction, 2 A + 2 B + 4 C => D + E + 3 F, Experiment Initial conc of A, mol/L Initial conc of B, mol/L Initial conc of C, mol/L Initial rate, mol/L.s 1 0.1 0.2 0.4 2 x 10-3 2 0.2 0.2 0.4 4 x 10-3 3 0.3 0.4 0.4 6 x 10-3 4 0.4 0.6 0.2 2 x 10-3 Calculate the value of k to 3 significant figures.
Find the value of a : b : c : d, if a : b = 2 : 3, b : c = 4 : 5 and c : d = 6 : 7.
Find the value of a : b : c : d, if a : b = 2 : 3, b : c = 4 : 5 and c : d = 6 : 7.
Activity Duration(hours) Depends on : Numbers of workers A 5 4 B 2 2 C 4...
Activity Duration(hours) Depends on : Numbers of workers A 5 4 B 2 2 C 4 5 D 6 A,B 1 E 2 A,B,C 6 F 2 B,C 3 G 5 F 4 H 8 E,F 2 I 3 G 7 J 5 H,I 3 K 6 J 4 L 8 I 3 Calculate a lower bound for the number of workers required to complete the project in 26 days. [2 ????] Use the precedence table to draw an activity-on-arc...
Evaluate (3b/2+c)*(6b-a) by writing the code in assembly. where a=2, b=3 and c=5. Write the equivalent...
Evaluate (3b/2+c)*(6b-a) by writing the code in assembly. where a=2, b=3 and c=5. Write the equivalent C++ code in assembly language. if (bx<= ax) && ( cx > dx ) { ax = 5; dx = 6; } NOTE: Only use 16 bit or 8 bit registers like ax,bx,cx,dx or al,bl,cl,dl. You can either do this using loop statement or conditional or unconditional jmps in assembly language. Keep the code as simple as possible. For question you need to use...
Complex Variable Evaluate the following integrals: a) int_c (z^2/((z-3i)^2)) dz; c=lzl=5 b) int_c (1/((z^3)(z-4))) dz ;...
Complex Variable Evaluate the following integrals: a) int_c (z^2/((z-3i)^2)) dz; c=lzl=5 b) int_c (1/((z^3)(z-4))) dz ; c= lzl =1 c) int_c (2(z^2)-z+1)/(((z-1)^2)(z+1)) dz ; c= lzl=3 (Details Please)
Given A*B*C and A*C*D, prove the corollary to Axion B-4.
Given A*B*C and A*C*D, prove the corollary to Axion B-4.
Given the following dataset x   1   1   2   3   4   5 y   0   2   4   5  ...
Given the following dataset x   1   1   2   3   4   5 y   0   2   4   5   5   3 We want to test the claim that there is a correlation between xand y. The level of cretaine phosphokinase (CPK) in blood samples measures the amount of muscle damage for athletes. At Jock State University, the level of CPK was determined for each of 25 football players and 15 soccer players before and after practice. The two groups of athletes are trained...
Given the following dataset x 1 1 2 3 4 5 y 0 2 4 5...
Given the following dataset x 1 1 2 3 4 5 y 0 2 4 5 5 3 We want to test the claim that there is a correlation between xand y. (a) What is the null hypothesis Ho and the alternative hypothesis H1? (b) Using α= 0.05, will you reject Ho? Justify your answer by using a p-value. (c) Base on your answer in part (b), is there evidence to support the claim? (d) Find r, the linear correlation...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT