Question:- What are the advantages of Python?
Answer:- Advantages of Python are: - Python is Interpreted language Interpreted: Python is an interpreted language. It does not require prior compilation of code and executes instructions directly. - It is Free and open source Free and open source: It is an open-source project which is publicly available to reuse. It can be downloaded free of cost. - It is Extensible Extensible: It is very flexible and extensible with any module. - Object-oriented Object-oriented: Python allows to implement the Object-Oriented concepts to build application solution. - It has Built-in data structure Built-in data structure: Tuple, List, and Dictionary are useful integrated data structures provided by the language. - Readability - High-Level Language - Cross-platform Portable: Python programs can run on cross platforms without affecting its performance.
Question:- What is PEP 8?
Answer:- PEP 8 stands for Python Enhancement Proposal, it can be defined as a document that helps us to provide the guidelines on how to write the Python code. It is basically a set of rules that specify how to format Python code for maximum readability. It was written by Guido van Rossum, Barry Warsaw and Nick Coghlan in 2001.
Question:- What do you mean by Python literals?
Answer:- Literals can be defined as a data which is given in a variable or constant. Python supports the following literals: String Literals - String literals are formed by enclosing text in the single or double quotes. For example, string literals are string values.
Question:- What is zip() function in Python?
Answer:- Python zip() function returns a zip object, which maps a similar index of multiple containers. It takes an iterable, convert into iterator and aggregates the elements based on iterables passed. It returns an iterator of tuples. Signature , zip(iterator1, iterator2, iterator3 ...)
Question:- How to overload constructors or methods in Pytho
Answer:- Pythons constructor: _init__ () is the first method of a class. Whenever we try to instantiate an object __init__() is automatically invoked by python to initialize members of an object. We cant overload constructors or methods in Python. It shows an error if we try to overload.
Question:- How to overload constructors or methods in Pytho
Answer:- Pythons constructor: _init__ () is the first method of a class. Whenever we try to instantiate an object __init__() is automatically invoked by python to initialize members of an object. We cant overload constructors or methods in Python. It shows an error if we try to overload.
Question:- What is the difference between remove() function and del statement?
Answer:- The user can use the remove() function to delete a specific object in the list.
Question:- What is swapcase() function in the Python?
Answer:- It is a strings function which converts all uppercase characters into lowercase and vice versa. It is used to alter the existing case of the string. This method creates a copy of the string which contains all the characters in the swap case. If the string is in lowercase, it generates a small case string and vice versa. It automatically ignores all the non-alphabetic characters.
Question:- How to remove whitespaces from a string in Python?
Answer:- To remove the whitespaces and trailing spaces from the string, Python providies strip([str]) built-in function. This function returns a copy of the string after removing whitespaces if present. Otherwise returns original string.
Question:- How to remove leading whitespaces from a string in the Python?
Answer:- To remove leading characters from a string, we can use lstrip() function. It is Python string function which takes an optional char type parameter. If a parameter is provided, it removes the character. Otherwise, it removes all the leading spaces from the string.
Question:- Why do we use join() function in Python?
Answer:- The join() is defined as a string method which returns a string value. It is concatenated with the elements of an iterable. It provides a flexible way to concatenate the strings.
Question:- Give an example of shuffle() method?
Answer:- This method shuffles the given string or an array. It randomizes the items in the array. This method is present in the random module. So, we need to import it and then we can call the function. It shuffles elements each time when the function calls and produces different output.
Question:- What is the use of break statement?
Answer:- The break statement is used to terminate the execution of the current loop. Break always breaks the current execution and transfer control to outside the current block. If the block is in a loop, it exits from the loop, and if the break is in a nested loop, it exits from the innermost loop.
Question:- What is tuple in Python?
Answer:- A tuple is a built-in data collection type. It allows us to store values in a sequence. It is immutable, so no change is reflected in the original data. It uses () brackets rather than [] square brackets to create a tuple. We cannot remove any element but can find in the tuple. We can use indexing to get elements. It also allows traversing elements in reverse order by using negative indexing. Tuple supports various methods like max(), sum(), sorted(), Len() etc.
