Tag Archives | coding

python-logo

Python Q&A – Functional Programming

Question 1: Writing Lambda Functions A lambda function is an anonymous function. The syntax for writing a lambda function is straightforward enough: variable_name = lambda argument_one, argument_two: return_value For example, we could write a simple lambda function which increments its argument: increment = lambda x: x + 1 We can then call this in exactly […]

Continue Reading 0
python-logo

Python Q&A – Recursion

Question 1: Recursion – Extracting Digits Recursion is a very useful way to iterate a condition over large amounts of data. In this example, it will be the simple use of recursion to extract the digits of the number inputted/analyzed. Task: Write a recursive function getdigits(n) that returns the list of digits in the positive […]

Continue Reading 0
python-logo

Python Q&A – Inheritance

Question 1: Using Inheritance A class which inherits from a superclass is called a subclass. The reason for using inheritance and subclasses is because some class can be broken down further (for example, an employee in a company is very general, and it is useful to have more information like what type of employee he […]

Continue Reading 2
python-logo

Python Q&A – Class Design

Question 1: Using Classes A class is a user-defined prototype for an object that defines a set of attributes that characterize any object in the class. Task: write a function print_friend_info(person) which accepts a single argument, of type Person, and: prints out their name prints out their age if the person has any friends, prints […]

Continue Reading 0

Powered by WordPress. Designed by WooThemes

Free WordPress Themes