- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Malhar Lathkar has Published 50 Articles
Malhar Lathkar
183 Views
Most commonly used str() function from Python library returns a string representation of object.>>> no=100 >>> str(no) '100' >>> L1=[1, 2, 3, 4] >>> str(L1) '[1, 2, 3, 4]' >>> d={'a': 1, 'b': 2, 'c': 3, 'd': 4} >>> str(d) "{'a': 1, 'b': 2, 'c': 3, 'd': 4}"However, repr() returns ... Read More
Malhar Lathkar
160 Views
Python tuple is an immutable object. Hence any operation that tries to modify it (like append/insert) is not allowed. However, following workaround can be used.First, convert tuple to list by built-in function list(). You can always append as well as insert an item to list object. Then use another built-in ... Read More
Malhar Lathkar
279 Views
Slicing operator can be used with any sequence data type, including Tuple. Slicing means separating a part of a sequence, here a tuple. The symbol used for slicing is ‘:’. The operator requires two operands. First operand is the index of starting element of slice, and second is index of ... Read More
Malhar Lathkar
115 Views
The built-in function tuple() converts a Python string into tuple of individual characters. It also turns a list object into a tuple.>>> tuple("TutorialsPoint") ('T', 'u', 't', 'o', 'r', 'i', 'a', 'l', 's', 'P', 'o', 'i', 'n', 't') >>> L1=[45, 32, 100, 10, 24, 56] >>> tuple(L1) (45, 32, 100, 10, 24, 56)
Malhar Lathkar
672 Views
Both List and Tuple are called as sequence data types of Python. Objects of both types are comma separated collection of items not necessarily of same type.SimilaritiesConcatenation, repetition, indexing and slicing can be done on objects of both types>>> #list operations >>> L1=[1, 2, 3] >>> L2=[4, 5, 6] >>> ... Read More
Malhar Lathkar
21K+ Views
Python sequence, including list object allows indexing. Any element in list can be accessed using zero based index. If index is a negative number, count of index starts from end. As we want second to last element in list, use -2 as index.>>> L1=[1,2,3,4,5] >>> print (L1[-2]) 4
Malhar Lathkar
2K+ Views
The slice operator in Python takes two operands. First operand is the beginning of slice. The index is counted from left by default. A negative operand starts counting from end. Second operand is the index of last character in slice. If omitted, slice goes upto end.We want last four characters. ... Read More
Malhar Lathkar
972 Views
Concept of variable in Python is different from C/C++. In C/C++, variable is a named location in memory. Even if value of one is assigned to another, it creates a copy in another location.int x=5; int y=x;For example in C++, the & operator returns address of the declared variable.coutRead More
Malhar Lathkar
112 Views
A string contains two integers separated by comma. It is first split in a list of two strings having digits.>>> s="1, 2".split(", ") >>> s ['1', '2']Two items are then converted to integers and used as arguments for complex() function>>> complex(int(s[0]), int(s[1])) (1+2j)This results in unpacking of string of integers ... Read More