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
python-logo

Python Q&A – Classes, Error Handling and I/O

Question 1: Accessing a Dictionary Dictionaries are iterable objects that store associations between ‘keys’ and values, which allow extraction of specific data by entering the specific key of the dictionary. Let’s say a dictionary: Meat = { ‘chicken’: 0, ‘beef’: 1, ‘pork’: 2} To extract the value of chicken, we would type Meat[‘chicken’] to get […]

Continue Reading 0
python-logo

Python Q&A – Classes and Objects

Question 1: Using Range Python has a built in function range, which returns an iterable sequence of numbers. Task: Write a function sum_range(start, end) which uses range to return the sum of the numbers from start up to, but not including, end. (Including start but excluding end is the default behaviour of range.) Write a […]

Continue Reading 0

Why WordPress is so popular?

WordPress is undoubtedly the most powerful Content Management System (CMS) on earth which remains free since 2003 founded by Matt Mullenweg and Mike Little. It is still by far the most used CMS, with 58.9% market share. It powers 28% of the websites globally according to the 2017 Survey conducted by w3techs. We are going […]

Continue Reading 0
python-logo

Python: Basic Questions – Functions & If Statements

Question 1: Using Functions Using a function to allow a “block of code” to take in arguments/values and returns a result. Task: Print 2*(n+1) to m using the double and increment functions provided. ‘2’ -> ‘6’ ‘0’ -> ‘2’ ‘-3’ -> ‘-4’ When given the functions: def increment(x): “”” Increment the argument (ie, return the […]

Continue Reading 0

Powered by WordPress. Designed by WooThemes

Free WordPress Themes