This section covers the general questions on Cli, Git, Python, Html and CSS.
Q1. How do you delete a specific stash in git?
-
You can delete a specific stash in git by the command:
$ git stash drop stash@{n}
Note: This command will permanently delete the stash.
Where n is the index number of the stash.
The indexing of the stash from 0 and goes on.
-
To search for a specific index in the stash, use the command:
$ git stash list
Q2. Why do we use "transform: translate" in CSS? Which browser doesn't support this CSS property?
- The transform: translate() property in CSS is used to move an element from its original position in the horizontal and/or vertical direction.
Q3. What is the difference between a "terminal" and a "console" in the context of Linux?
Terminal: A terminal is a program that provides a user interface to access the shell, which is the command-line interface of the operating system.
Console: The console is the physical device or interface that allows you to interact with the system directly without any graphical interface.
Q4. What is the difference between "grep" and "find" commands in Linux?
Grep: The grep command is used to search for specific text patterns within files. It can search for a single pattern or multiple patterns using regular expressions.
Find: The find command is used to search for files and directories based on certain criteria, such as file name, date modified, or file type. It can also perform actions on the files found, such as copying, moving, or deleting them.
Q5. If there are 3 items in a row, how do you position the item in the third column to the first column using a grid?
-
You can use the below command:
grid-column:1;
grid-column used in grid layouts to define both the start and end positions of a grid item within a grid column.
It accepts two values: the starting grid line and the ending grid line for the item in the column axis.
This command will set the 3 items in a row to the first column.
-
As an alternative to the above command you can also use the below command.
grid-column-start:1;
grid-column-start is a CSS property used in grid layouts to define the start position of a grid item within a grid column.
Q6. How can you slice a list in Python?
The word slice means to get a specific piece of an object. In python, slicing presents the specified part of the object.
-
To put it in more simple words. Here is an example in python:
>>> l1 = ['abcd', 1 , 'hello', True, 45.2, 68] >>> l1[2:4] >>> ['hello', True]
-
The syntax for slicing is:
object-name[start:end:step]
- Start: Specify the index where you want to start.
- End: Specify the index up to the required end.
- Step: Specify if you want to skip the slice in steps.
Q7. Why do we need the concept of transactions in SQL? What does it help us to achieve?
Transaction is a sequence of operations performed on a database that is considered to be a single logical unit of work. Transactions can consist of one or more database operations, such as inserting, updating, or deleting records.
Transactions are needed in a database system to ensure data consistency and integrity.
When multiple operations need to be performed together, such as transferring funds from one bank account to another, it is essential to ensure that either all the operations succeed, or none of them does.
Without transactions, a failure in the middle of such operations could leave the database in an inconsistent state, causing data corruption and loss.
To avoid data corruption and loss, transactions are used.
Q8. What is the use of an iframe tag?
An iframe is an HTML element used to embed another HTML document inside the current document.
-
The Syntax to use the iframe tag is:
<iframe src="URL"></iframe>
Q9. What is the difference between a descendant and a child selector?
-
A descendant selector is used to select all elements that are descendants of a specified parent element, regardless of how many levels down the hierarchy they are.
div a { /* CSS rules go here */ }
-
A child selector, on the other hand, only selects direct children of a specified parent element. It uses the > symbol to separate the parent and child elements in the selector.
div > a { /* CSS rules go here */ }
Q.10 What is the difference between discard() and remove() in Python?
discard() and remove() method removes the specified item in a set.
The major key difference is discard method doesn't throw an error when the specified key is not present not in the set but the remove method throws an error when the specified key is not present in the set.
ADD-ONS: You will find a similar explanation for some similar commands in the list and dictionary.
Q.11 Can you join a table with itself and if so how?
- Yes, a table can be joined with itself, and this is known as a SELF JOIN.
- A self-join is useful when a table contains a foreign key that references its primary key.
- You can also use INNER JOIN with a different alias to join the table with itself or use sub-queries.
Q.12 What is the difference between a view and a temporary table in SQL?
A view and a temporary table are both database objects, but they serve different purposes and have different characteristics.
A view is a virtual table that is based on the result of a SQL query. It is not a physical table and does not store data itself, but instead retrieves and displays data from one or more underlying tables.
A temporary table is a physical table that is created and used for a specific session or transaction. Temporary tables are usually created for the temporary storage of data that is only needed for a short period.
Temporary tables are not stored permanently in the database and are automatically deleted at the end of the session or transaction.
In summary, views are virtual tables that provide a simplified interface to the data, while temporary tables are physical tables that are used for the temporary storage of data during a session or transaction.
Q13. What is the z-index property in CSS?
- The z-index property in CSS is used to control the vertical stacking order of elements on a web page.
- It specifies the stack order of an element relative to other elements on the page.
- Elements with a higher z-index value are displayed on top of elements with a lower z-index value.
- The z-index property can be applied to any positioned element (position: absolute, position: relative, position: fixed, or position: sticky).
Top comments (0)