NEW
Font size
WorksheetsRevision module 3
Total questions: 10
Worksheet time: 5mins
Which module in Python supports regular expressions?
re
regex
pyregex
none of the mentioned
Which of the following creates a pattern object?
re.create(str)
re.regex(str)
re.compile(str)
re.assemble(str)
The character Dot (that is, ‘.’) in the default mode, matches any character other than _____________
caret
ampersand
percentage symbol
newline
The function of re.search is:
Matches a pattern at the start of the string
Matches a pattern at the end of the string
Matches a pattern from any part of a string
Such a function does not exist
The output of the two codes shown below is the same. State whether true or false.
p = re.compile('hello')
r = p.match('hello everyone')
print(r.group(0))
r = re.match('hello', 'hello everyone')
print(r.group(0))
True
False
May be
Can't say
To open a file c:\scores.txt for reading, we use
infile = open(“c:\scores.txt”, “r”)
infile = open(“c:\\scores.txt”, “r”)
infile = open(file = “c:\scores.txt”, “r”)
infile = open(file = “c:\\scores.txt”, “r”)
The readlines() method returns
str
a list of lines
a list of single characters
a list of integers
Which of the following returns a string that represents the present working directory?
os.getcwd()
os.cwd()
os.getpwd()
os.pwd()
What will be the output of the following Python code?
x=10
y=8
assert x>y, 'X too small'
Assertion Error
10 8
No output
108
The module used to move ,copy,delete and rename files in Python program is
Path
Os
shutil
