• Q & A – Pandas Basics

    Q & A – Pandas Basics

    (1) What Is Pandas In Python? Pandas is an open-source, python-based library used in data manipulation applications requiring high performance. The name is derived from “Panel Data” having multidimensional data. This was developed in 2008 by Wes McKinney and was developed for data analysis. Pandas are useful in performing 5 major steps of data analysis – Load the data, clean/manipulate it, prepare it, model it, and analyze the data. (2) Define Pandas dataFrame? A data frame is a 2D mutable and tabular structure for representing data labelled with axes – rows and columns. The syntax for creating a data frame:

    Read More

  • Q & A – Python Advanced

    Q & A – Python Advanced

    (1) How Are Arguments Passed By Value Or By Reference In python? Pass by value: A copy of the actual object is passed. Changing the value of the copy of the object will not change the value of the original object. Pass by reference: Reference to the actual object is passed. Changing the value of the new object will change the value of the original object. In Python, arguments are passed by reference, i.e., reference to the actual object is passed. Example-1: def appendNumber(array): array.append(4) arr = [1, 2, 3] # Mutable Object print(arr) appendNumber(arr) print(arr) [1, 2, 3] [1,

    Read More

  • Q & A – Python Miscellaneous.

    Q & A – Python Miscellaneous.

    (1) What is Python? What are the benefits of using Python What Is Python: Python is a high-level, interpreted, general-purpose programming language. Being a general-purpose language, it can be used to build almost any type of application with the right tools/libraries. Additionally, python supports objects, modules, threads, exception-handling, and automatic memory management which help in modelling real-world problems and building applications to solve these problems. Benefits Of Using Python: Python is a general-purpose programming language that has a simple, easy-to-learn syntax that emphasizes readability and therefore reduces the cost of program maintenance. Moreover, the language is capable of scripting, is

    Read More

  • Q & A – Python Dictionary

    Q & A – Python Dictionary

    (1) What Is A Python Dictionary? How Does It Work? Python Dictionary objects are data types that are enclosed in curly braces ‘{}’ and have key and value pairs and each pair is separated by a comma. The dictionary is mapped. Meaning since it has key and value pair, a meaningful key can save a lot of trouble for coders, like using an address key to save all the addresses, an id key for all id’s and so on. Moreover, as of Python >3.6, dictionaries also preserve the order. Example-1 student = {‘Name’:’Subrat’, ‘Subject’:’Math’, ‘Mark’:88} print(student) {‘Name’: ‘Subrat’, ‘Subject’: ‘Math’,

    Read More

  • Q & A – Python Set

    Q & A – Python Set

    (1) What Is A Set Data Structure? A Set is an unordered collection data type that is iterable, mutable and has no duplicate elements.  Set is represented by { } (values enclosed in curly braces) The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for checking whether a specific element is contained in the set.  This is based on a data structure known as a hash table. Since sets are unordered, we cannot access items using indexes as we do in lists. Example-1 st = {1,4,2,5,1,3,3,4} print(st) {1, 2, 3, 4,

    Read More

  • Q & A – Python Tuple

    Q & A – Python Tuple

    (1) What Is A Tuple Data Structure? Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Set, and Dictionary, all with different qualities and usage. Tuples are used to store multiple items in a single variable. A tuple is a collection which is ordered and unchangeable. Example-1 tp = (1,’abc’,4.5,[9,8]) print(type(tp)) print(tp) <class ‘tuple’> (1, ‘abc’, 4.5, [9, 8]) (2) Find The Size Of The Tuple In Python. getsizeof() Function can be used to get the size of the tuple. The getsizeof() function belongs to the python’s sys module. Example-1 import sys

    Read More

  • Q & A – Python List

    Q & A – Python List

    (1) Check If A List Contains An Element. The in operator will return True if a specific element is in a list. lst = ['Subrat','Arpita','Abhispa','Subhada'] 'Subhada' in lst True (2) How To Iterate Over 2+ Lists At The Same Time. You can zip() lists and then iterate over the zip object. A zip object is an iterator of tuples. Below we iterate over 3 lists simultaneously and interpolate the values into a string. name = ['Snowball', 'Chewy', 'Bubbles', 'Gruff'] animal = ['Cat', 'Dog', 'Fish', 'Goat'] age = [1, 2, 2, 6] z = zip(name, animal, age) for i, j, k in z: print(f"Name: {i} Animal: {j} Age: {k}")

    Read More

  • Q & A – Python Numbers

    Q & A – Python Numbers

    (1) Check If A Number Is Positive, Negative or 0. num = float(input(‘Enter A Number ‘)) if num > 0: print(‘Positive Number’) elif num < 0: print(‘Negative Number’) else: print(‘Zero’) (2) Check If A Number Is Odd or Even. num = float(input(‘Enter A Number’)) if num % 2 == 0: print(‘Even Number’) else: print(‘Odd Number’) (3) Check A Year Is Leap Year Or Not. We have discussed above, we know that because the Earth rotates about 365.242375 times a year but a normal year is 365 days, something has to be done to “catch up” the extra 0.242375 days a

    Read More

  • Q & A – Python String

    Q & A – Python String

    (1) What Is A String Datatype? A String is a collection of a sequence of characters. A String can contain Alphabetic, Numeric, or Special characters. A String variable is enclosed within a single(”) or double quote(“”). A String type in Python is of the ‘str’ type. Example-1 name = 'Subrat Kumar Sahoo' print(name) Subrat Kumar Sahoo Example-2 password = "hallo@123" print(password) hallo@123 Example-3 country = 'India' print(country) India (2) How To Check Existence Of A Character Or A Sub-string In A String? You can use ‘in’ keyword to check the existence of a sub-string in a string. Example-1 "pass" in

    Read More

  • SQL – How To Alter SQL Table?

    SQL – How To Alter SQL Table?

    SQL – How To Alter SQL Table? Table Of Contents: What Is Altering A Table? Syntax Of Altering A Table. Examples Of Altering A Table. (1) What Is Altering A Table? The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used to add and drop various constraints on an existing table. (2) Syntax Of Altering A Table? Adding A Column: ALTER TABLE table_name ADD column_name datatype; Dropping A Column: ALTER TABLE table_name DROP COLUMN column_name; Renaming A Column: ALTER TABLE table_name RENAME COLUMN old_name to new_name; Modifying Datatype Of A Column:

    Read More