180k views
0 votes
Question 1:State the values of a, b, c, d and e after the following operations are carried out:

(a) a = 26 mod 5
b) b = 142 div 7
(c) c = (7 + 3) * 4 – 1
(d) d = 15.6 / 3 + 4.8 / 2
(e) e = “4” + “56”

Question 2: The function ord (’a’) evaluates to 97, the ASCII value of the character ‘a’.
chr (97) evaluates to ‘a’.
State what is output by this algorithm:
x = ord (‘b’)
y = x + 1
z = x – 1
w = chr (y) + chr (z)
print (x, y, z, w)

Question 3: What is output by the following algorithm?
notice = “Please do not walk on the grass”
start = pos (notice, “ “)
end = pos (notice, “t”)
x = substring (0, start, notice)
stringLength = len(notice)
y = substring (end + 2, stringLength – 1, notice)
print (“x = ” x)
print (“y = “, y)
print (x + y)

PLEASE HELP ME WITH THIS QUESTIONS I DON'T KNOW HOW TO DO IT I'M LITERALLY CRYING RIGHT NOW CAN SOMEONE HELP ME THIS QUESTIONS PLEASE T-T T-T T-T

1 Answer

2 votes

Answer:

1.

a = 1

b = 20(int). 20,2857143(double)

c = 39

d = 7.6

e = 456

2.

x = 98

y = 99

z = 97

w = ca

print(x,y,z,w) -> 98 99 97 ca

3.

x = Please

y = walk on the gras

Pleasewalk on the gras

Step-by-step explanation:

you can use IDE/Interpreter python to get clue number 3 and number 2

Sorry for bad English.

User Pmttavara
by
4.3k points