Professional Documents
Culture Documents
Ex2_1 Convert the following sentences into logical expressions (conditions) using
Python.
Ex2_2 Find the logical result (True or False) from these conditions, given that
the variables are assigned to the following values:
Α = 10, Β = 2, C = -4, D = 9 and Ε = 1
iii. not (Ε<=C) or (D<=C) ~ not False or False ~ True or False ~ True
iv. not ((Β<=C) and (D<2)) ~ not (False and False) ~ not False ~ True
X = 2
Y = X ** 2 - 1
Z = 2 * X + Y - 1
if X > Y:
Y = Z % X
Z = X ** 2
else:
X = Z % Y
Z = Y ** 2
print(X)
print(Y)
print(Z)
Χ : 2 0
Υ : 3
Z : 6 9
Ex2_4 Find the output of the given code below?
a = 3
b = 1
c = 5
if (a % 2 == 1) or (b >= 2):
c =c + 2
if (c < b):
a = a ** 3
else:
b = 4 * b
a = a % b
b = b % c
c = c % a
print(a)
print(b)
print(c)
(3 % 2 = 1) or (1 >= 2) 7 < 5
True Not True
a : 3 3
b : 1 4 4
c : 5 7 1
Ex2_5 Write an algorithm that reads the e-value of a BLAST similarity search
and prints whether the e-value is significant or not (significant E-value 1e-5 or
lower.
Ex2_6 Write an algorithm that reads an integer x and calculates and prints
the value of the following mathematical function. Is there an “x-value” that
should not be accepted / processed (Tip: a division with zero cannot be defined)?
x = input ('Enter a value for x: ' )
if x != 1:
fx = (3*x)/(x-1)**2
print(fx)
else:
print('not defined')
Ex2_7 Write an algorithm that reads an integer x and calculates and prints
the value of the following mathematical function.
Ex2_8 Write an algorithm that reads the gene copy number from deep
sequencing experiments and prints corresponding messages according to the
following: If the copy number is less than 2 the gene is expressed poorly, if the
copy number is more than 2 but less than 5, the gene is moderately expressed, if
the copy number is more than 5 but less than 15, the gene is actively expressed,
finally if the copy number is more than 15, the gene is expressed very actively.
Ex2_9 Write an algorithm that reads three numbers and prints out the
smallest of the three.
Ex2_10 Write an algorithm that reads two RNA sequences and checks if the
first is a subsequence of the second. (NB:- you should check that the sequence is
RNA (string sequence of any A,U,G,C letter) and not DNA (string sequence of
any A,T,G,C letter) and only if it is RNA continue to check if the first is a
subsequence of the second).