sample questions

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/11

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

12 Terms

1
New cards
2
New cards

a. Compiler

A compiler is a program that translates source code written in a high-level programming language into machine code. It allows a program to be executed by a computer.

3
New cards

b. Syntax Error

A syntax error occurs when code violates the grammatical rules of the programming language, preventing it from being parsed or executed.

4
New cards

c. Argument

An argument is a value or variable passed to a function when it is called, used by the function to perform its task.

5
New cards

What is the output of type(x) after the following statements are executed: x=3

6
New cards

x=[4]

7
New cards

x='5'

8
New cards

What is the value stored in x after: x = y[2]

'c'

9
New cards

What is the value stored in x after: x = y[:2]

['a', 'b']

10
New cards

What is the value stored in x after: x = y

['a', 'b', 'c', 'd']

11
New cards

Write a function which calculates the GC content of an input sequence

def gc_content(seq):
[tab] gc = sum(1 for base in seq if base in 'GCgc')
[tab] return (gc / len(seq)) * 100 if seq else 0

12
New cards

The following code contains Syntax Errors. Correct them, highlighting changes with underlined font

#!/usr/bin/env python3

import sys

with open(sys.argv[0], 'r') as instream, open(sys.argv[1], 'w') as outstream:

[tab]for line in instream

[tab] [tab] line = line.rstrip()

[tab] [tab] if 'this" in line:

[tab] [tab]outstream.print("Found a line with 'this':"{}.format(line))

[tab] outstream.print("Complete")

sys.exit()

#!/usr/bin/env python3

import sys

with open(sys.argv[1], 'r') as instream, open(sys.argv[2], 'w') as outstream:

for line in instream:

line = line.rstrip()

if "this" in line:

outstream.write("Found a line with 'this': {}\n".format(line))

outstream.write("Complete\n")

sys.exit()

<p>#!/usr/bin/env python3  </p><p>import sys  </p><p>with <mark data-color="yellow" style="background-color: yellow; color: inherit">open</mark>(sys.argv[<mark data-color="yellow" style="background-color: yellow; color: inherit">1</mark>], '<mark data-color="green" style="background-color: green; color: inherit">r'</mark>) as instream, open(sys.argv[2], 'w') as outstream:  </p><p>    for line in instream:  </p><p>        line = line.rstrip()  </p><p>        if "this" in line:  </p><p>            outstream.write("Found a line with 'this': {}\n".format(line))  </p><p>    outstream.write("Complete\n")  </p><p>sys.exit()</p>