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

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.
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...
1. a. Evaluate the following limit: lim ?→4 ( 2? 3−128 √?−2 ) (8 marks) b....
1. a. Evaluate the following limit: lim ?→4 ( 2? 3−128 √?−2 ) b. Find the number ? ???ℎ ?ℎ?? lim ?→−2 ( 3? 2+??+?+3 ? 2+?−2 ) exists, then find the limit
A, B, C, D are all matricies A = 2x3 1 2 −3 −1 4 5...
A, B, C, D are all matricies A = 2x3 1 2 −3 −1 4 5 , B = 2x3 3 0 −1 1 2 1 , C = 2x2 2 5 1 2 , D = 3x3 1 −1 1 2 −1 2 4 −3 4 Find each of the following or explain why it does not exist. 1) A + B, 2) 2A − 3B, 3) A + C, 4) A − C, 5) AC, 6) CA, 7)...
Evaluate ∫ C ( 2 x − y ) d x + ( 4 y −...
Evaluate ∫ C ( 2 x − y ) d x + ( 4 y − x ) d y where C consists of the line segment from( 0 , 1 ) to ( 1 , 0 ), followed by the line segment from ( 1 , 0 ) to( 3 , 0 ), followed by the line segment from ( 3 , 0 ) to ( 2 , 2 ). Submit answer as a number rounded to two decimal...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT