Posts

Featured Post

SQL Interview Success: Unlocking the Top 5 Frequently Asked Queries

Image
 Here are the five top commonly asked SQL queries in the interviews. These you can expect in Data Analyst, or, Data Engineer interviews. Top SQL Queries for Interviews 01. Joins The commonly asked question pertains to providing two tables, determining the number of rows that will return on various join types, and the resultant. Table1 -------- id ---- 1 1 2 3 Table2 -------- id ---- 1 3 1 NULL Output ------- Inner join --------------- 5 rows will return The result will be: =============== 1  1 1   1 1   1 1    1 3    3 02. Substring and Concat Here, we need to write an SQL query to make the upper case of the first letter and the small case of the remaining letter. Table1 ------ ename ===== raJu venKat kRIshna Solution: ========== SELECT CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2))) AS capitalized_name FROM Table1; 03. Case statement SQL Query ========= SELECT Code1, Code2,      CASE         WHEN Code1 = 'A' AND Code2 = 'AA' THEN "A" | "A

Python Tuple: Here're 2 Ways to Calculate Sum Easily

Image
Python tuple is nothing but a set of data. It can have an 'n' number of elements. Here, in my example, the tuple has 20 Elements. The below logic helps you to calculate the sum of its 20 Elements easily.  A tuple is simply a set, and it can have both positive and negative Elements. So, don't worry. You can calculate the sum even the tuple has negative numbers. Here are 2 Ways You can calculate Sum Display sum after adding each element Display sum at once   Python Logic: #1 Method - The Print Displays Sum in Vertcle after Adding Each Element my_tuple = (1,20, -30, 50, 10, 11, 6, 7, 22, 88, 10, 20, 565, 121, 211, 5, 2, 18, 20, 21) sum = 0 for index in my_tuple:             sum = sum+ index          print("sum of elements:", sum) Note*** Here the print statement is within the For Loop. You May Also Like: How to Use For Loop  in Python Complete Tutorial Python Logic: #2 Method - The Print Displays Total Sum at once my_tuple = (1,20, -30, 50, 10, 11, 6, 7, 22, 88, 10

Python Subset: How to Get Subset of Dictionary

Image
Here's a sample program to get the python subset. In this case, you'll find logic for dictionary subsets. Dictionary python To illustrate, I have taken a dictionary as below with keys and values. my_first_dict = { 'HP': 100 'IBM': 200 'NTT': 300 'ABC': 400 'GDF': 500 } I want to make a subset of values greater than 100 and less than 400. How can you achieve this? No worries, below, you will find the logic. Logic to get subset out of a dictionary I am using dictionary comprehension to achieve this. Syntax: sub_set = { key:value for key, value in my_first_dict.items() value >100 and value <400} Result References Python Programming: Using Problem-Solving Approach

Python Default Argument is Self Why do We Need it

Image
Python self as default argument, here is the reason. Below, you will find an example and the importance of self-argument. Structure of a class The default argument is self. The self-argument states the function belongs to the class that we refer to here. Access to class members' details of one member to another is possible through self-argument. So self-argument is mandatory. class <name of the class>: def <function name>(<arguments>): ... <members> Self Argument A python class consists of methods these also called functions. The default self-argument you need to supply in all the class methods . Python class with self argument class employee:      def getdata(self):           self.name=input('Enter name\t:')           self.age=input('Enter age\t:')     def putdata(self):           print('Name\t:',self.name)          print('Age\t:',self.age)  e1=employee()  e1.getdata()  e1.putdata() Output from python class Here,  I have I

Python Abstract Classes to Learn Quickly

Image
Here's the best example of how to understand the abstract classes of python quickly. An abstract class means it is a skeleton. You cannot instantiate abstract classes. For Example: The abstract class name is 'dog' o = dog() It gives an error. Since the ' dog' is an abstract class. I am sharing with you a clear understanding of abstract class. So that you can tell confidently about these classes. The syntax for Abstract Class from abc , import ABC , abstractmethod  class <class name>(ABC): @abstractmethod  def <method name>():  #abstract class definition Python Abstract Class Explanation from abc import ABC, abstractmethod class AbsBaseClass(ABC): def __init__(self): print("Abstract class") @abstractmethod def abMeth(self): pass def conMeth(self): print("I'm a concrete method") class Derived(AbsBaseClass): def abMeth(self): print("I'm redefined") o=Derived() o.abMeth() o.conMeth() References Star Python Certification

10 Kafka Interview Questions That Recently Asked

Image
Kafka Interview Questions Here're ten interview questions that were asked during Kafka's interview.  These are useful to update your knowledge. 1. What is Kafka? Kafka is a framework of Publisher and Subscribe. It reads messages from the Producer and allows them to read by Subscribers. It keeps store all the producer messages in the form of topics (underlying partitions). It also maintains logs. 2. What is a Consumer group? Each consumer is part of some Consumer group. By adding more consumers to a Consumer group, you can balance the load. In general, the Consumer group reads data from the same topic. The number of partitions in a Topic always should be the same as Consumers in a particular CG (consumer group). 3. What is Fault-Tolerance? Each partition is replicated on multiple servers. So, when one partition is failed, the other backup will deliver. So this concept is called Fault-tolerance. 4. Can we decrease the partitions that we created? No, you can't decrease the par

10 Tech Mahindra Fresher Interviews Questions

Image
Here're the ten top interview questions asked during fresher interviews. These are general questions and applicable for all B. Tech branches. 10 Interview Questions These are general interview questions who is looking for job either on/off campus drives. 1. What is Full-Service Web-hosting? It is a service offered by website hosting companies. So that the site can be accessed via the world wide web. 2. What is meant by Port blocking within LAN? It restricts the users to access services through various ports. The ports are USB, DVD port, Floppy, Removal device ports. 3. What is IDN? It enables people to use Domain names in local languages. 4. Can we call one program (not include) from another program? Yes, you can call. Here not include means external program. 5. How can you sort the elements of an array in descending order? In C++, you can use Array.Reverse(arr); 6. How do I update my DNS records? You can update DNS records in CNAME. Here're more options. 7. How do non-root -br

Print Dictionary Values Simplified Logic

Image
Here's for loop logic that says how to use Dictionary to get its data. I will present here how to use it as input In for loop. You can also call Dictionary as Map, Hash, or Associative array. Print dictionary values Below is my example. I have created a simple Dictionary called 'store.' Then, I will get its data using for-loop. Here's my previous post Python -  How to Lookup Dictionary By Key . Dictionary example Store = { "rao" : 1, "srini' : 2} For-loop logic for key in store:       print (key, store[key]) Laptop batteries can last longer if you charge them up to only 80% instead of the full 100%. - By Lifehack.org Real-time result The execution of for loop showed here. It's much simple. Just use the code as I did. You'll get the desired result quickly. References Python for Everybody: Exploring Data in Python 3 SOFT SKILLS for a BIG IMPACT: Banish Self-Doubt, Improve Workplace Ethics