mcdb 170 midterm

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Q: What is not an assignment operator? A. = B. == C. *= D. /= E. +=

B

Q: Which statement is True? A. A list can have a single type of data. B. A list allows easy data manipulation. C. A list is an elemental data type of Python. D. A list cannot have another list as its element.

B

Q: Which one is a wrong statement? A. 1 is an integer B. 1.0 is a float C. '1' is a string D. 1 is a Boolean

D

Q: Which statement is True? A. A function cannot be used to recycle code. B. A function can only accept one parameter. C. A function must return a value. D. A function can return multiple values

D

An array 'x' contains numbers from 100 to 199. How can we select even numbers between 120 and 150 inclusive.import numpy as npx = np.arange(100,200) a. y = x[(x>=120) & (x<=150) & (x%2==0)] b. y = x[(x>=120) & (x<=150) & (x%2==1)] c. y = x[(x>120) & (x<=150) & (x%2==0)] d. y = x[(x>=120) & (x<150) & (x%2==0)]

a

If we are working with a DataFrame df indexed by year, what would df.loc[1914:1918] return? a. A DataFrame including all rows with index between 1914 and 1918 (included), if any. b. A DataFrame including all rows with index between 1914 and 1918 (excluded), if any. c. The subset of the index that lies between 1914 and 1918. d. A DataFrame including all rows with index equal to 1914 or 1918.

a

In genome, terC, the replication terminus, is where replication completes and two DNA strands finish separation. If we compute G-C skew profile and plot it, where can we find the terC? a. At the maxima b. At the average point c. At the median point d. At the minima

a

In the following code, you won't see any outcome. What is the problem? counter = 0 while counter >= 0: counter += 1; print(counter) a. It is in an infinite loop b. It uses the colon in a wrong place c. The last line with the 'print' function should be indented. d. Semicolon generates an error

a

To access an attribute of a class instance (i.e., to access a variable inside a class instance), which syntax should we use? a. . b. = c. * d. [ ] e. ( ) Feedback Your answer is c

a

We want to combine multiple functions into a class. Which of the following is not a good practice? a. We can simply copy and paste all necessary functions under class definition. b. Saving the class as a module helps the re-use of the code in other programs. c. Function arguments should be modified to include 'self' as the first argument d. If necessary, the return values may need to be replaced to modify member variables using 'self'.

a

We want to know how many time a base occurs in a DNA sequence. Which of the following expression uses a generator expression? a. seq = 'ATGATTCGATGT'base = 'G'count = sum(c == base for c in seq) b. seq = 'ATGATTCGATGT'base = 'G'count = sum([c == base for c in seq]) c. seq = 'ATGATTCGATGT'base = 'G'l = []for c in seq:l.append(c==base)count = sum(l) d. seq = 'ATGATTCGATGT'base = 'G'count = 0for c in seq:count = count + int(c == base)

a

What is NOT happening in the following code?import numpy as npx = np.arange(100)y = x*3 a. 'y' has 300 elements where number from 0 to 99 repeating 3 times. b. 'x' has 100 elements from 0 to 99 c. The last statement 'broadcasts' the addition operation across all elements. d. 'y' has 100 elements from 0 to 297 with step size of 3

a

What is NOT true about the following code?a = [1,2,3]b = a*3 a. The variable 'b' has [3,6,9] b. The variable 'a' is a list c. Lists do not provide arithmatic operations. d. The variable 'b' has [1,2,3,1,2,3,1,2,3]

a

What is the output of the following code? v1 = 10v2 = v1 # v2 is copied v1 = 8 print(v2) t1 = [42, 1024, 23] t2 = t1 t3 = t1.copy() t1[1] = 6print(t2) print(t3) a. 10[42, 6, 23][42, 1024, 23] b. 8[42, 1024, 23][42, 1024, 23] c. 8[42, 1024, 23][42, 6, 23] d. 10[42, 6, 23][42, 6, 23]

a

What is the printed value of this code? def add(a,b=1): return(a+b) n=add(2) n=add(n,n) print(n) a. 6 b. 7 c. 4 d. 3 e. 5

a

What is true? a. NumPy provides syntactic sugars resembling normal mathematical operations b. NumPy is not used in Biopython c. NumPy uses a linked list as its base memory structure. d. NumPy is a part of the core Python language

a

What's the output of this code? mammals = ["human", "monky", "mouse", "rat", "cat", "dog"] mammals[3:5] = ["horse", "elephant"] mammals.sort() print(mammals) a. ['dog', 'elephant', 'horse', 'human', 'monky', 'mouse'] b. ["human", "monky", "mouse", "rat", "cat", "dog"] c. ['mouse', 'monky', 'human', 'horse', 'elephant', 'dog'] d. ['human', 'monky', 'mouse', 'horse', 'elephant', 'dog']

a

Which of the following code does NOT have any error? a. for x in range(5):print(x) correct b. for x from range(5):print(x) c. for x in range(5)print(x) d. for x in range(5):print(x)

a

Which of the following does *not* select the column 'Mass' in a pandas DataFrame, object? a. object['Mass'] b. object.loc[:,'Mass'] c. object.Mass d. object.loc['Mass']

a

Which of the following does NOT generate an array of [1, 2 ,3] a. import numpy as npx = np.arange(3) b. import numpy as npx = np.array([1,2,3]) c. import numpy as npx = np.arange(1,4) d. import numpy as npx = np.linspace(1,3,num=3,dtype=np.int64)

a

Which of the following is an appropriate way to use explicit indexing to slice a Pandas series of state average incomes (called v)?import pandas as pdimport numpy as npv = pd.Series({"MA": 100000.0,"VA": 100001.0,"CA": 100002.0,"DE": 100003.0,"TX": 100004.0,"FL": 100005.0,...}) a. v.loc[:'TX'] b. v.loc[:4] c. v.iat[:'FL'] d. v.iloc[:'CA']

a

Which of the following is true? a. Generator does not make a temporary memory space b. It is often difficult to understand a condensed expression of dictionary comprehension c. Comprehension efficiently uses the memory d. Generator expression saves execution time

a

Which of the following statements about Pandas is False? a. Pandas provides a faster numerical operation than Numpy. b. Conceptually, pandas' dataframe behaves similar to Excel spreadsheet. c. Pandas' dataframe can be considered as a multi-dimensioanl array with labels for columns and rows. d. Pandas support diverse data reading functions for file types including the CSV file type and the Excel file type. e. The type of columns in the dataframe can be different.

a

What are true about the difference between Python and C programming language? (select all) a. C is closer to machine language than Python b. C programing language is a compiled language whereas Python is a interpreted language c. C is slower than Python d. C provides an interactive interface whereas Python supports multiple fast compiling pipelines.

a &b

What are compiled languages? (select all) a. C b. Python c. Matlab d. C++

a &d

Which of the following can be used as variable names? (select all) a. not_a_variable b. _2good_name c. _special_ d. 1st_name e. @address_of_4th_var f. else

a,,b,c

We want to combine the following list of DNA letters into a string in the same order.q = ['T', 'A', 'G', 'T', 'C', 'T', 'A', 'C']Which of the following code does NOT combine it properly? (Select all correct answers.) a. s = q.join('') b. s = 'A'*2 + 'T'*3 + 'G'*1 + 'C'*2 c. s = ''.join(q) d. s = ''for b in q:s = s+b

a,b

What are true about this code? (select all)import math as mt a. We need to use 'mt' prefix followed by '.' followed by a name of function to use a function the math package. b. We can now calculate sin(pi) by "mt.sin(pi)". c. We can now use many math functions. d. After this statement, to access functions of "math" module, we need to use "math." prefix.

a,c

Which of the following are true? (select all) a. Data structure affects the performance of algorithms. b. Efficient algorithms can handle any data structures equally well. c. Linked list is not efficient in adding or removing elements d. Array is efficient for search

a,d

Which of the following are true? Select all. a. Biopython provides all the tools necessary to automate remote BLAST, download matching sequences, and multiple sequence alignment. b. NCBI does not accept random random sequence of genes for BLAST. It should be a real biological sequence obtained from experiments. c. BLAST does not provide alignment result that can be downloaded and analyzed locally. d. BLAST is a paired sequence alignment algorithm e. It is not possible to control MUSCLE with Python

a,d

The following code describes an ODE function. It generates errors. What are those errors? (select all)1 def ODE_function(s,t):2 x, y, z = s3 dxdt = x + y4 dydt = z + s5 dzdt = k - x^26 dsdt = x+y+z78 return np.array([dxdt, dydt, dzdt, dsdt]) a. In line 4, dydt will have three elements and needs to be debugged. b. In the function signature, s and t should be switched. c. The return value has a different dimension from the input that has ODE varialbes. The dimension should be the same. d. The return value is an np.ndarray. But ndarray cannot be made from this list because dydt and dsdt are not simple numbers but arrays.

all

Consider a dataset containing salary information for U.S. citizens. It has a column 'salary', a column 'sex', and a column 'teacher'. The column 'teacher' has boolean values of whether a citizen is a teacher or not. How would you use the Pandas package to calculate the average salary of female teachers? a. numpy.mean(data['sex','teacher']) b. data.groupby(['sex', 'teacher']).mean() c. data.set_index(['sex','profession']) d. none of these answers

b

In the lecture "Calculus refresh" by Dr. Louis, the difference between time derivatives and integration of an athlete's running was described. Which is False in the following choices? a. Integration of velocity describes the total distance. b. Derivative of distance describes acceleration. c. Integration of acceleration describes the velocity. d. Derivatice of velocity decribes the change of velocity.

b

The following code generated output as shown. Why is there only one entry of 'France' in the result? # Codecapitals = {'United States': 'Washington, DC', 'France':'Marseille', 'France':'Paris', 'Italy':'Rome'} print(capitals) # Output{'United States': 'Washington, DC', 'France': 'Paris', 'Italy': 'Rome'} a. Dictionaries cannot have duplicate keys. b. Because a "set" can have only one 'France'. c. This Python interpreter seems to have a bug. d. Because the capital of France is Paris, not Marseille.

b

The following code generates an error. Why?import mathprint(sin(math.pi/2)) a. pi is not defined in the math package b. sin function is missing 'math.' prefix. c. The function should be 'sine', not 'sin' d. 'import' should be replaced with 'from'

b

The following function should print "Hi, Sung" when called, but has many issues. Which is not an issue? def hiSung: print(Hi, Sung) a. A keyword 'func' should be used instead of 'def'. correct b. Indetaion for the print statement is missing. c. Parentheses are missing. d. Quotation marks for the string are missing.

b

We want to find k-mer's. However, the sequential matching algorithm was extremely slow to use. Which of the following is NOT true? a. We need a more efficient algorithm b. It was an O(k*N) algorithm. c. It was an O(k*N^2) algorithm. d. It takes thousands or millions of hours to finish for a long genome.

b

We want to measure the average time to run a function we developed in the class: "rand_dna_seq()". Which of the following magic commands would run it many times automatically and measure the average of the running time? a. %debug rand_dna_seq(100) b. %timeit rand_dna_seq(100) c. %run rand_dna_seq(10) d. %time rand_dna_seq(10000)

b

What is an advantage of a class over a tuple? a. Tuples can replace class b. Class can have methods c. Tuple's naming convention is complex d. Class is memery efficient

b

What is the outcome of the following code? a = "12"print(type(a)) a.b float b. str correct c. complex d. int

b

What's the keyboard shortcut to add a cell below the current cell (assuming that you are already in the command mode)? a. b c d

b

Which explicit indices can Pandas arrays use? a. none of these answers b. numerical and non-numerical indices c. non-numerical indices only d. numerical indices only

b

Which of the following is the most common way of organizing case/variable data in a spreadsheet? a. Cases in columns, variable and value pair in rows b. Cases in rows, each variable in a separate column c. Cases in rows, with the case identifier followed by variable: value pairs d. Each case as a separate table, variables in rows

b

Which values does range(5, 25, 5) iterate through? a. 0, 5, 10, 15, 20 b. 5, 10, 15, 20 c. 5, 10, 15, 20, 25 d. 5, 25, 5

b (step size 5 and doesn't put highest part)

Which of the following are true? (select all) a. FASTA format has comments for individual genes. b. FASTA format has a simpler organization than GenBank format c. FASTA format has less information than GenBank format d. FASTA format and GenBank format may have different IDs for the same gene e. FASTA file format can only have one chromosome sequence in a single file. f. FASTA format may not be converted into GenBank format

b,c,f

Let's say we developed a few functions for genetic sequence analyses. Then, later we decided to combine all these functions into a single class. Which of the following are good practices? (select all) a. It is best to hide the function names in the class so that users can only access variables. b. Function arguments sould be modified to include 'self' as the first argument c. We can simply copy and paste all necessary function under class defition. d. Where necessary, the return values may need to be replaced to modify member variables using 'self'.

b,d

What are true statements about Python function arguments (this is about regular functions, not about class methods)? (select all) a. The data type of each argument must be defined in the first line of the function definition. b.If you specify the name of arguments when call a function, the order of the arguments does not matter. c. The first argument must be the object of its caller. d. Each argument can have a default value.

b,d

A program is consisted of data and instructions. Which of the following is not data? a. dictionaries b. sets c. if-elif cluase d. lists e. tuples

c

In Python, how do you block code? a. Use keyword 'end' b. Use semicolon ';' c. Use indentation d. Use braces {}

c

The following code is in an infinite loop. What is NOT a way to get out of the loop?counter = 1while counter > 0:counter += 10;print(counter) a. Use a for-loop instead, with a finite list b. Check the value of "counter" and break the while loop when it reaches to a certain value c. Use a different variable name, "limted_counter", than "counter" d. Change the conditional expression after 'while' so that counter is in a limited range.

c

Using comprehension, convert the following code into a single line code. cubes = list() for i in range(30): if i%5 == 2:cubes.append(i**3) a. cubes = [ k**3 for k in range(30) ] b. cubes = [ i**3 for k in range(35) if k%5 == 2 ] c. cubes = [ k**3 for k in range(30) if k%5 == 2 ] d. cubes = [ i for i in range(30) if i%5 == 2 ] Feedback Your answer is correct.

c

We want to select rows with an element in column 'A' is less than -1 and an element in column 'B' is greater than 1. But it generates an error. How can we fix it?selected = df[ df["A"] < -1 & df["B"]>1 ] a. selected = df[ df["A"] < -1 && df["B"]>1 ] b. selected = df[ df["A"] < -1 and df["B"]>1 ] c. selected = df[ (df["A"] < -1) & (df["B"]>1) ] d. selected = df[ df[ "A" < -1 & "B">1 ] ]

c

What does dict.items(), where dict is a Python dictionary, iterate over? a. All keys from the dictionary b. All keys from the dictionary, then all values c. All pairs (key, value) from the dictionary d. All values from the dictionary

c

What does the following code do? m *= 7 a. Increase the value of 'm' by 7 b. This is a grammar error. c. Multiplies the value of 'm' with 7 and stores it in 'm' d. The value of 'm' will be multiplied by 7 and the outcome will be returned to the caller of this expression.

c

What does the following code print?import numpy as npx = np.array( [ x**2 for x in range(3,9,2) ] )print(x) a. [ 6 10 14] b. [ 9 25 49 81] c. [ 9 25 49] d. [ 6 10 14 18]

c

What is the type of the variable 'x' in the following code?import numpy as npx = np.array([1,2,3]) a. list b. numpy.matrix c. numpy.ndarray d. numpy.narray e. numpy.array

c

What is true about Euler's method? a. Euler's method is the most accurate method to simulate ODEs b. Euler's method describes how to get the time derivative of a function. c. Euler's method allows numerical integration of time-derivatives. d. Euler's method is not sensitive to the delta of t between two time points of the function that it integrates.

c

Which of the following is NOT a legal way to create a Pandas DataFrame? (Note: A couple of methods in this quiz were not covered in the lecture. Test them in the JupyterLab.) a. pd.DataFrame([{'integer': 1, 'square': 1}, {'integer': 2, 'square': 4}, {'integer': 3, 'square': 9}]) b. pd.DataFrame([(1,1), (2,4), (3,9)], columns=['integer','square']) c. pd.DataFrame(integer=[1,2,3], square=[1,4,9]) d. pd.DataFrame({'integer': [1,2,3], 'square': [1,4,9]})

c

Which of the followings is used to assign a value to a new variable? a. . b. [ ] c. = d. <- e. ( )

c

Which syntax should we use to 'call' a function or a method? a. [ ] b. = c. ( ) d. -> e. .

c

Which of the following are true? (select all) a. Comprehension makes a small temporary memory space to sequentially access individual items b.Generator is always faster than comprehension. c. Comprehension is a python idiom, which was developed to make the code more human readable. d. Generator efficiently uses the memory

c,d

A program is consisted of data and instructions. Which of the following represent data? (select all) a. def b. for c. float d. dictionary e. integer

c,d,e

Which of the following is wrong? a. BLAST provides alignment data that can be downloaded and analyzed locally. b. We can perform alignment analysis with any random sequence of genes to the entire database of genome in NCBI c. Biopython provides all the tools necessary to automate remote BLAST, download matching sequences, and multiple sequence alignment. d. MUSCLE is an online alignment tool that we can download the results. e. BLAST is a multiple sequence alignment algorithm

c,e

DnaA binds to DnaA box in OriC. We assumed that there may be more than one DnaA boxes in OriC. Why? a. DnaA boxes are special sequences that make the split of double helix easier. b. Because DnaA boxes are rare to find. c. Statistically say, there must be multiple DnaA boxes. d. DnaA may miss it easily if there are not enough DnaA boxes in the OriC.

d

To represent the directory structure, Windows uses backslashes, '\', and Linux and maxOS use forward slashes, '/'. How can we ensure that our code is portable across these platforms? a. Use 'input()' to ask the users which platform they use. b. Type in the exact directory we want to use in the code c. Always use the forward slashes '/' because Python is used in the UNIX-like environment. d. Use the Python 'os' package functions such as 'path.join()

d

What is False about Numpy arrays and and Pandas dataframe? a. Both provides multi-dimensional arrays for fast operation. b. Dataframe provides labels to each elements. c. Numpy array operations provides computational foundation whereas Pandas dataframe provides efficient ways to manipulate complex real world data. d. Numpy cannot handle missing data

d

What is correct about the following code? from Bio import Entrez Entrez.email = "your_email_address" net_handle = Entrez.efetch( db="nucleotide", id='NM_206006.2', rettype="gbwithparts", retmode="text" ) a. It saves the data into a local disk b. It retrieves information in FASTA format c. It retrieves information from "genome" database d. It retrieves information about a gene with ID:NM_206006.2 from NCBI e. It sends an email to Entrez to reply with the sequence.

d

What is the type of variable 'k' and 'p' in the following code? p = 397.0 k = '210' a. 'p' is a float and 'k' is an integer. b. Both are integers c. 'p' is an integer and 'k' is a string. d. 'p' is a float and 'k' is a string

d

What's the keyboard shortcut to execute a cell in the Jupyter Lab? a. Enter (or Return) b. Esc c. Alt+Enter d. Shift+Enter

d

Which of the following is False when you copy a list variable "var1" to another list variable "var2"? a. Statement "var2 = var1" copies the reference to the 1st level sequence data. b. Statement "var2 = var1.deepcopy()" copies all sequences at all levels. c. Statement "var2 = var1.copy()" copes the first level sequence from var1 to var2. d. Statement "var2 = var1" copies the entire sequence of data from var1 to var2.

d

Which of the following is not true about the following code?import numpy as npx = np.array([1 , 2. , 3]) a. x.shape is (3,) b. x.ndim is 1 c. x.size is 3 d. x.dtype is 'int64'

d

Which of the following is wrong? a. Biopython provides packages supporting 3D crystal structure analysis b. Biopython provides packages to analyze biological sequences c. Biopython provides tools to parse GenBank files. d. Biopython provides tools to record the behaviors of molecules in the cell.

d

Which of the following is wrong? a. FASTA format and GenBank format has the same ID for the same gene b. FASTA format cannot be converted into GenBank format c. FASTA format has a simpler organization than GenBank format d. FASTA format has more information than GenBank format

d

Which range construct would generate the values 2,7,12, and 17? a. range(17) b. range(0,17,5) c. range(17,5) d. range(2,18,5)

d

Which values does range(3, 15, 2) iterate through? a. 3, 5, 7, 9, 11, 13, 15 b. 3, 15, 2 c. 2, 4, 6, 8, 10, 12, 14 d. 3, 5, 7, 9, 11, 13

d

This code is from the lecture.class petClass(): def __init__(self, name, color="brown"): self.name = nameself.color = colordef petColor(self): print(self.name, 'is', self.color)def dye(self, color): self.color = colorself.petColor()p = petClass('Puddle','gold')q = petClass('Border Collie', 'black and white')Which of the following statement are False? (select all) a. p and q are different instances of the class perClass. b. p.dye('black') will change the p.color to 'black' c. petClass has two member variables: name and color. d. q.name is 'Puddle' e. p.petColor() will print out "Border Collie is black and white"

d,e

What is not the advantage of Python over C Programming language? a. You can write a shorter code b. The grammar is easier to understand c. You can immediately see the result of each line of code d. You can run numerical analysis faster

d. python is slower

Which of the following is not true? a. Array is efficient for search b. Data structure affects the performance of algorithms. c. Linked list is efficient in adding or removing elements d. Efficient algorithms can handle any data structures equally well.

e

1-dimensional Numpy array is a column vector. Select one: True False

false

A Python module performs tasks by itself. Select one: True False

false

All species on earth has a unique oriC. Select one: True False

false

Big O notation is used to measure the absolute amount of time to run an algorithm for a small number of data. Select one: True False

false

DNA polymerase replicate the DNA in the forward direction (in the parent strand): that is, from 5' to 3'. Select one: True False

false

In List, we can use a key to access a value. Select one: True False

false

In the computer, the instructions are stored in CPU. Select one: True False

false

Python is a compiled language. Select one: True False

false

Seq object has SeqRecord object as its member variable. Select one: True False

false

Seq object of Biopython is mutable. Select one: True False

false bc not a list

t or f: key must be unique

t

Forward half strand of the DNA is replicated slowly, which results in more mutations Select one: True False

true

G-C skew plot as we march the DNA strand in the forward direction may peak at terC (the terminus). Select one: True False

true

In biological science, it is important to convert a qualitative question into a measurable and testable quantitative question. Select one: True False

true

To remove the "end of line" charactor from each line while reading a DNA sequence from a text file, we use ".strip()" function. Select one: True False

true

Tuples are mutable sequence and Lists are immutable sequence. Select one: True False

true


Set pelajaran terkait

The Legacy of WW1 and The Armistice

View Set

FISIOLOGÍA Homeostasis y Transporte Celular

View Set

chapter 4 taxes, retirement and other insurance concepts

View Set

Strategy Game Theory Grant Chapter

View Set