API - Application Program Interface

API - Application Program Interface

anagram

detect_anagrams(word, candidates)[source]

Determine if anagram of word exists in the given list of candidates.

Parameters:
  • word (str) – word to be tested
  • candidates (list) – potential list of anagrams
Returns:

item from candidates that is an anagram of word if one exists

Return type:

list

bob

class Bob(statement)[source]

Class to provide Bob’s response to a given statement.

Attributes:
  • statement: original query posed to Bob
  • response: Bob’s response to the query
Staticmethods:
  • hey:
  • silent: response to silent query
  • yell: response to yell query
  • question: response to question query
  • remainder: response to all other queries
hey()[source]

Function will provide Bob’s response to a given statement.

static silent()[source]

Bob’s reply to a silent query.

static yell()[source]

Bob’s reply to a yell query.

static question()[source]

Bob’s reply to a question query.

static remainder()[source]

Bob’s reply to all remaining queries.

difference_of_squares

sum_of_squares(n)[source]

Calculate the sum of the squares for the first n natural numbers.

Parameters:n (int) – number of natural numbers to be operated on
Returns:sum of the square for 1 to n
Return type:int
square_of_sum(n)[source]

Calculate the square of the sum for the first n natural numbers.

Parameters:n (int) – number of natural numbers to be operated on
Returns:square of the sum of 1 to n
Return type:int
difference(n)[source]

Calculate the difference between the square of sums and the sum of squares.

Parameters:n (int) – number of natural numbers to be operated on
Returns:difference between square of sums and sum of squares
Return type:int

gigasecond

add_gigasecond(initial_date)[source]

Function will determine date 1E9 seconds in the future from given date.

Parameters:initial_date (<datetime_object>) – datetime object for the initial date
Returns:date 1E9 seconds ahead of initial date
Return type:<datetime_object>

hamming

distance(strand_1, strand_2)[source]

Function will calculate the hamming distance between the two given DNA strands.

Parameters:
  • strand_1 (str) – string of DNA
  • strand_2 (str) – string of DNA
Returns:

hamming distance

Return type:

int

hello_world

Module contains function to greet user.

hello(name='')[source]

Return user greeting if name is provided else state Hello World!

Parameters:name (str) – user’s name

leap

even_div(dividend, divider)[source]

Function will determine if the quotient of the dividend and the divider is even or not.

Returns:True if division of the dividend by the divider has no remainder
Return type:bool
is_leap_year(year)[source]

Function will determine if the input is a leap year.

Parameters:year (int) – integer of year to be evaluated
Returns:True if leap year and False if not
Return type:bool

meetup

meetup_day(year, month, day_of_week, option)[source]

Function will determine the date of meetup.

Parameters:
  • year (int) – year of meetup
  • month (int) – month of meetup
  • day_of_week (str) – name of meetup day
  • option (str) – modifier for choosing meetup (1st, 2nd, 3rd, 4th, first, last, teenth)
Returns:

date of meetup

Return type:

datetime object

rna_transcription

to_rna(strand)[source]

Function will convert DNA sequences to RNA sequences

Parameters:strand (str) – string of DNA nucleotides
Returns:string of RNA nucleotides
Return type:str

wordcount

class Phrase(phrase)[source]

Class will collect attributes related to phrases.

Attributes:
  • phrase: string of words
word_count()[source]

Display the words in a phrase and number of times each word is used.

Returns:dictionary of words and the number of times they occur in phrase
Return type:dict