Here are a few examples of JSON messages: A simple JSON object representing a person’s name and age: { “name”: “John Smith”, “age”: 30 } A JSON object representing a collection of books: { “books”: [ { “title”: “The Great Gatsby”, “author”: “F. Scott Fitzgerald”, “year”: 1925 }, { “title”: “To Kill a Mockingbird”, “author”: […]
What’s JSON? (JavaScript Object Notation)
JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition – December 1999. JSON is a text format that is completely language independent but […]
Write a Python function that validates a user input to be N digits separated by N-1 commas.
def check_input_format(user_input): if not user_input: return False if not user_input[0].isnumeric() or not user_input[-1].isnumeric(): return False try: input_list = user_input.split(“,”) input_list = [int(x) for x in input_list] except ValueError: return False if len(input_list) != len(set(input_list)): return False return True The check_input_format(user_input) function takes in a user’s input as a string, and checks if it follows the […]
Write a Python function that sorts a user-input string entry.
def sort_string(string): # Split the string into a list of integers nums = [int(x) for x in string.split(‘,’)] # Sort the list of integers nums.sort() # Join the sorted list of integers back into a string sorted_string = ‘,’.join([str(x) for x in nums]) return sorted_string This Python function sort_string(string) takes in a string as an […]
What’s Robotic Process Automation (RPA)?
RPA (Robotic Process Automation) is a technology that allows businesses to automate repetitive, rule-based tasks that are typically performed by humans. It has become increasingly popular in recent years as a cost-effective way to improve efficiency, reduce errors, and increase productivity. Many experts believe that RPA will continue to be a promising area in the […]
What’s polymorphism in OOP anyway? An example with C++.
Polymorphism in object-oriented programming (OOP) is the ability of a single function or method to operate on multiple types of data. One common use of polymorphism in C++ is through the use of virtual functions. Here is an example: class Shape { public: virtual double area() = 0; }; class Rectangle: public Shape { private: […]
What’s overloading in OOP anyway? An example with C++.
In object-oriented programming (OOP), overloading refers to the ability of a class or its member functions to have multiple implementations with different parameters. An example of overloading in C++ would be a class called “Calculator” that has several different versions of a function called “add”: class Calculator { public: int add(int a, int b); double […]
What’s inheritance in OOP anyway? An example with C++.
### class Shape { public: double getArea() { return 0.0; } }; class Rectangle: public Shape { private: double width, height; public: Rectangle(double w, double h) { width = w; height = h; } double getArea() { return width * height; } }; int main() { Rectangle rect(3, 4); cout << “Area of rectangle: ” […]