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

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

All About Init and Delete Constructors Python

Image
Python class has two constructors. One is the init, and the other one is del. Why do you need these two and their real purpose explained? The initialization method is called __init__ while the finalization or destructor method is called __del__. Python methods with a double underscore character are for internal (not intended for direct access by the outside world) use. There are no true private methods in Python classes, but convention says that a method that begins with a single underscore is considered private, and a double underscore indicates it is internal (only to be used by the system.) Python Constructors  Init Constructor object.__init__(self[, ...]) Called after the instance has been created (by  __new__() ), but before it is returned to the caller. The arguments are those passed to the class constructor expression.  If a base class has an  __init__()  method, the derived class’s  __init__()  method, if any, must explicitly call it to ensure proper initialization of the base

Python Delete Duplicates in List Faster Way

Image
Removing duplicates in List simplified using SET method. It's a simple method. Just you need SET and Print to remove duplicates. Removing duplicates is common in Data science projects. What is list A list is a collection of elements. The elements can be duplicates or non-duplicates. Today's task is to remove duplicate elements in the List. Faster way to remove list duplicates Create a List Use SET Print the result List with duplicates my_list = ['The', 'unanimous', 'Declaration', 'of', 'the', 'thirteen','united', 'States', 'of', 'America,', 'When', 'in', 'the', 'Course', 'of', 'human'] Apply set method >>> non_dupes = set(my_list) Print Final list >>> print(non_dupes) Here, if you observe, there are no duplicates. The duplicates are now removed. It displays only non-duplicate values.  Here 'the' is a duplicate value. That'

How to Fix datetime Import Error in Python Quickly

Image
Here's a quick resolution for import datetime Python error . The reason is your .py python script name and datetime  are the same. I'll show you how this error happens and its resolution.   Here's the Resolution for ImportError I've created a script called 'datetime.py.' to check whether the minute value is 'odd' or not. During the import of my python script, I got the import error cannot import name datetime. My Script: datetime.py My script's intention is to find whether the minute value is odd or not. Python Logic from datetime import datetime odds = [ 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 , 17 , 19 , 21 , 23 , 25 , 27 , 29 , 31 , 33 , 35 , 37 , 39 , 41 , 43 , 45 , 47 , 49 , 51 , 53 , 55 , 57 , 59 ] right_this_minute = datetime.today().minute if right_this_minute in odds: print ( "This minute seems a little odd." ) else : print ( "Not an odd minute." ) ImportError I have imported my datetime.py from Linux. It gives an error

How to Count Vowels in Input Quickly

Image
Here you'll know how python counts characters in the input. This is an interview question asked recently. How to Count Vowels in Input String Below is the Interview Question Vowels = ('aeiou') You need to check any vowels are present in the input string. Vowels means 'a', 'e', 'i', 'o', 'u'. The below function checks each character of input and compares it with the Vowels. 3 Steps to Count Vowels in Input You can achieve this in three steps. 1. Create a function called 'my_vowel' (the name up to you) 2. Use Set & Intersection Method 3. Run the function 1. Created 'my_vowel' Function #!usr/bin/python #This function finds vowel counts #welcome to my function """ Optional description """ def my_vowel (a): vowels = set ( 'aeiou' ) a_1 = vowels . intersection( set (a)) # initialized the dictionary found = { 'a' : 0 , 'e' : 0 , 'i' : 0 ,