CIS 245 test 2

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

Which code joins three separate strings 'join', 'this' and 'string' together, and returns this output: 'join*this*string'

'*'.join(['join','this','string'])

Which regex syntax will match only the first 3 digits in a string '06518'?

(r'(\d){3,5}?')

Which regex syntax while analyzing the string 'song, long, strong, wrong, sponge' produces the output: ['song', 'long', 'trong', 'wrong' , 'spong']

(r'.{1,3}ng')

Which regular expression would match the string '5,000'?

(r'\d,\d\d\d')

What is an appropriate regex syntax to match a zip code in this format '90601'?

(r'\d\d\d\d\d')

Which regex syntax requires that the match should start and end with a digit?

(r'^\d+$')

How would you write a regex that matches a number with commas for every three digits? It much match the following: '42' '1,234' '6,368,745' but not the following: '12,34,567' (which has only two digits between the commas) '1234' (which lacks commas)

(r'^\d{1,3}(,\d{3})*$')

What regex syntax is used for matching any number of repetitions?

*

What does the following expression evaluate too? 'May'.lower().upper()

MAY

What are the functions that are defined in a class and describe the behavior of an object?

Methods

What escape character is used to display text on a new line?

\n

In regular expressions which character class represents a new line character?

\s

In regex, which meta character matches the beginning of a string?

^

Which module extracts data from HTML pages?

beautiful soup

In the module openpyxl, which attribute is used to retrieve the row number and column letter of a cell?

coordinate

Which attribute returns the column count in the worksheet?

max_column

Which attribute returns the row count in the worksheet?

max_row

Finish this program, by adding a line of code from the choices below, to get the first matched object?

mo.group()

Which code returns a workbook object in Python?

openpyxl.load_workbook()

Which code is the most appropriate to create a new workbook object?

openpyxl.workbook()

Which os method changes the current working directory to a given path?

os.chdir()

Which os method returns a string that contains the path to the current working directory?

os.getcwd()

Which regular expression matches the phone number in this format 203-333-3333 where the area code is required?

r'(\d\d\d)+\d\d\d-\d\d\d\d'

Which method is used to create Regex objects?

re.compile

Which Regex method returns the first match object of the string?

search()

Using openpyxl, how would you retrieve the value stored in cell B6 from the object named 'sheet'?

sheet'['B6'].value

How would you set the width of column X to value 20?

sheet.column_dimensions['X'].width = 20

How would you set the height of row 5 to value 25?

sheet.row_dimensions[5].height - 25

How would you create a variable 'sheet' that is assigned to a worksheet named 'Accounts' from the workbook object names 'wb'?

sheet= wb['Accounts']

How would you retrieve the value stored in cell A10 from the worksheet object named 'sheet'?

sheet['A10'].value

Which code inserts a formula = SUM(B1:B10) in cell B11?

sheet['B11']= '=SUM(B1:B10)'

What does the following expression evaluate to? 'It is Friday'[1]

t

Which code is the most appropriate to create a new worksheet in the object named 'wb'?

wb.create_sheet()

Which code is the most appropriate to save a workbook in the variable 'wb'?

wb.save()

Which code returns the names of worksheets from the object named 'wb'?

wb.sheetnames

Which method is the most appropriate to delete a worksheet?

del

What does the following expression evaluate to? 'Friday'.upper().lower()

friday

Which regular expression makes the area code required in the example below?

r'(\d\d\d-)+\d\d\d-\d\d\d\d'

Which regular expression makes the area code option in the example below?

r'(\d\d\d-)?\d\d\d-\d\d\d\d'

Which string method is used to right justify a string?

rjust()

Which code adds an additional row to a worksheet?

sheet.append()

Which code is the most appropriate to assign a string value 'Report' to cell D1 in the object?

sheet['D1'] = 'Report'

Which code is the most appropriate to assign an integer value 2000 to cell E1 in the object 'sheet'?

sheet['E1'] = 2000

Which methods would remove whitespace characters from this string? spam= ' It is Friday '

spam.strip()

If numRegex = re.compile(r'\d+'), what will numRegex.sub('X', '12 books, 11 pens, four pencils, 3 notebooks') return?

'X books, X pens, four pencils, X notebooks'

What does this regex expression match? numRegex = re.compile (r'(\d){3,5}?') numRegex.search ('0123456789')

012

What does the following expression evaluate to? 'CIS 245' [:5]

CIS 2

In regex, which meta character matches the end of a string?

$

What does the following expression evaluate to? 'Friday'.upper()

FRIDAY

In regular expressions, which type of matching would match the longest possible pattern?

Greedy

What does the following expression evaluate to? 'It is Friday' [:5]

It is

What does the following expression evaluate to? 'Friday'.upper().isupper()

True

When does the findall() method return a list of tuples of strings?

When the Regex has groups

Which regex syntax is used to match alternative objects?

a pipe ( | )

What escape character is used to match special regex characters * + or ?

\

How would you express a \ backslash character in a string?

\\

What data type does the attribute max_column return?

integer

Which string method returns True when the string contains only letters and numbers?

isalnum()

How would you retrieve the active sheet from the workbook object named 'wb'?

wb.active


Set pelajaran terkait

CH 11 Administering a Tube Feeding

View Set

Network Pro Part 2 ++++++++++++++++++++

View Set

Ch. 14 Integration of Nervous System and Functions

View Set

Chapter 12-Spatial Orientation and the Vestibular System

View Set

Side By Side 2: Chapter 7 (Vocabulary)

View Set