TCS
10+ Interview Questions and Answers
Q1. Write a Program for reversing a string without using inbuilt methods
Program to reverse a string without using inbuilt methods
Create an empty string to store the reversed string
Loop through the original string from the end to the beginning
Add each character to the empty string
Return the reversed string
Q2. What are the Python data structures and about oops
Python data structures include lists, tuples, sets, and dictionaries. OOPs is a programming paradigm.
Python data structures are used to store and organize data in a program
Lists are ordered and mutable, tuples are ordered and immutable, sets are unordered and unique, and dictionaries are unordered key-value pairs
OOPs is a programming paradigm that focuses on creating objects that have properties and methods
In Python, classes are used to create objects and encapsulate data and...read more
Q3. What is decorator with an example
Decorator is a design pattern that allows behavior to be added to an individual object, either statically or dynamically.
Decorator pattern involves a set of decorator classes that are used to wrap concrete components.
Decorators provide a flexible alternative to subclassing for extending functionality.
An example of decorator pattern is adding toppings to a pizza. Each topping is a decorator that wraps the pizza object.
Another example is adding borders, shadows, and other effec...read more
Q4. How to perform crud operations in python
CRUD operations in Python can be performed using various libraries and frameworks.
Use SQLalchemy ORM for database operations
Use Flask or Django for building web applications
Use pandas library for data manipulation
Use file handling functions for file operations
Q5. Types of path and which one is used
There are two types of paths - relative and absolute. Both are used depending on the context.
Relative paths are used to navigate within the current directory or subdirectories.
Absolute paths are used to navigate to a specific location in the file system.
Examples of relative paths: './file.txt', '../folder/file.txt'
Examples of absolute paths: '/home/user/file.txt', 'C:/Users/user/Documents/file.txt'
Q6. Program for create list from given dictionary
A program to create a list from a given dictionary.
Iterate through the dictionary and append each key-value pair to a list.
Use list comprehension to create a list from the dictionary.
Sort the list based on keys or values if required.
Q7. What is pickling and unpickling
Pickling is the process of converting a Python object into a byte stream, while unpickling is the reverse process.
Pickling is used to store Python objects in a file or transfer them over a network.
Unpickling is used to retrieve the original Python object from the stored byte stream.
The pickle module in Python is used for pickling and unpickling.
Example: Pickling a list - pickle.dump([1, 2, 3], open('data.pkl', 'wb'))
Example: Unpickling a list - pickle.load(open('data.pkl', 'r...read more
Q8. Difference of deep copy and shallow copy
Deep copy creates a new object with the same values as the original, while shallow copy creates a new object with references to the original's values.
Deep copy duplicates all nested objects and their values, while shallow copy only duplicates the top-level object.
Deep copy is more memory-intensive and time-consuming than shallow copy.
Example of deep copy: copying a list of dictionaries using deepcopy() in Python.
Example of shallow copy: copying a list using slice notation in ...read more
Q9. Explain Django Architecture
Django follows Model-View-Controller (MVC) architectural pattern.
Django has a high-level architecture that follows the Model-View-Controller (MVC) architectural pattern.
The Model layer represents the database schema and business logic.
The View layer handles the presentation logic and renders the templates.
The Controller layer acts as an intermediary between the Model and View layers.
Django also includes a URL routing system and middleware for handling HTTP requests and respon...read more
Q10. Types of locators in selenium
Locators in Selenium are used to identify web elements on a web page. There are several types of locators available.
Types of locators in Selenium include ID, Name, Class Name, Tag Name, Link Text, Partial Link Text, CSS Selector, and XPath.
ID and Name locators are the most commonly used and are unique to each element.
Class Name and Tag Name locators are used to identify multiple elements with the same class or tag name.
Link Text and Partial Link Text locators are used to iden...read more
More about working at TCS
Interview Process at null
Reviews
Interviews
Salaries
Users/Month