Skip to content

Latest commit

 

History

History

Part2

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Day1Part2

Python exercise

Description

  1. Print the numbers as follows 5 9 13 17 21

  2. 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

  1. Consider the following list x = [1, 2, 2.3, 'hello', True, '7'] Create a new list with only the integers.

  2. 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)

  3. Consider the following code.

def add(x, y): z = x + y

a = 1 b = 2 c = add(a, b) print(c)

  1. What is the value of c and the output?
  2. What are the global and local variables?
  3. What do you have to do to change the output to 3?
  4. 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?