Python exercise
-
Print the numbers as follows 5 9 13 17 21
-
You are given 2 lists x = [1, 2, 3, 4] y = ['a', 'b', 'c', 'd']
Using only a single for loop ensure that the output is the following 1 d 2 c 3 b 4 a
-
Consider the following list x = [1, 2, 2.3, 'hello', True, '7'] Create a new list with only the integers.
-
Convert a DNA strand into its RNA counterpart. A DNA strand consists of 4 bases A T G C which have their corresponding bases in RNA U A C G. So A corresponds to U, T to A, G to C and C to G. Given a DNA strand such as AATCAGCTCG we must get back UUAGUCGAGC. (Hint: Dictionary)
-
Consider the following code.
def add(x, y): z = x + y
a = 1 b = 2 c = add(a, b) print(c)
- What is the value of c and the output?
- What are the global and local variables?
- What do you have to do to change the output to 3?
- after placing the return statement and re-running the ENTIRE code, what are the values of a, b, c, x, y, z after the last print statement?