1/11
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
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.
b. Syntax Error
A syntax error occurs when code violates the grammatical rules of the programming language, preventing it from being parsed or executed.
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.
What is the output of type(x) after the following statements are executed: x=3
x=[4]
x='5'
What is the value stored in x after: x = y[2]
'c'
What is the value stored in x after: x = y[:2]
['a', 'b']
What is the value stored in x after: x = y
['a', 'b', 'c', 'd']
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
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()