Question: Help with these functions on python Implement each of the following functions. We will be checking that you actually use the string methods and formatting

Help with these functions on python

Help with these functions on python Implement each of the following functions.

Implement each of the following functions. We will be checking that you actually use the string methods and formatting as proscribed! def count_digit_leading_lines(text): Accept a string text representing multiple lines and count how many lines starts with a digit (0-9). Return an integer as the counting result. Restriction (and hint): you must use .split() and probably other built-in string methods. count_digit_leading_lines ("AAA 1st") rightarrow 1 # 2^nd line starts w/digit 1 count_digit_leading_lines ("\t4G Hz ") rightarrow 0 # 1^st line starts w/tab count_digit_leading_lines ("0 0 3 n4 ") rightarrow 2 def date (month, day, year): Accepting integers for the month (values from 1 to 12), the day (values from 1 to 31) and the year (values from 1 to 9999). Construct the correct date representation, as the examples below. You can assume that value of day is always a valid one for the given year and month. Restriction: you must use string formatting, either % or .format(). date(2, 29, 2016) rightarrow "02/29/2016" date(11, 8, 2008) rightarrow "11/08/2008" date(1, 3, 1) rightarrow "01/03/0001" def show_table(table): Given table as a list of lists of strings, create and return a formatted string representing the 2D table. Follow these requirements (examples below): Each row of the 2D table is on a separate line; the last row is followed by an empty line Each column is aligned to the left; Columns are separated with a single vertical bar '|'; and there must be exactly one space before and after the vertical bar; Every row starts and ends with a vertical bar; and there must be exactly one space after the leading bar and before the ending bar Restriction: you must use string formatting, either % or .format(). >> show_table([["A", ' BB'], ['C', 'DO']]) '| A | BB | | C | DD | ' >>> print(show_table([['A', 'BB'], ['C', 'DD']])) | A | BB | | C | DO | >>> show_table([['A, 'BBS', 'C'], ['1', '22', '3333']]) '| A | BBB | C | | 1 | 22 | 3333 | ' >>> print(show_table([['A', 'BBB', 'C'], ['1', '22', '3333']])) | A | BBB | C | | 1 | 22 | 3333 | >>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!