Malhar Lathkar

Malhar Lathkar

About

Malhar Lathkar has been teaching different programming technologies for last three decades. After completing M.Sc. Electronics, he started his career as Lecturer in Electronics. Fascinated by Computer languages and programming, he started his own software training and development centre in 1986. Thousands of undergraduate and PG students as well as professionals have been trained by him. His students are working with many of the leading IT companies across the world. He has always encouraged students to be entrepreneurs and many of them are having their own successful IT ventures. He is associated with TIEC (Technology Innovation Entrepreneurship Center) set up by SGGSIE&T Nanded. He has designed many software solutions with applications in Banking, Healthcare, automation etc. His teaching is deeply influenced by his experience in software development. Java, Python, PHP and database technologies are his areas of interest and expertise. Besides he is an avid sports enthusiast, a freelance columnist for a local Marathi daily and relishes Hindustani classical music.

24 Articles Published

Articles by Malhar Lathkar

Page 2 of 3

How does == operator works in Python 3?

Malhar Lathkar
Malhar Lathkar
Updated on 26-Feb-2020 206 Views

The == symbol is defined as equality operator. It returns true if expressions on either side are equal and false if they are not equal>>> (10+2) == 12 True >>> 5*5 == 5**2 True >>> (10/3)==3 False >>> 'computer'=="computer" True >>> 'COMPUTER'.lower()=='computer' True

Read More

What does 'is not' operator do in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 26-Feb-2020 579 Views

In Python, is and is not operators are called identity operators. Each object in computer's memory is assigned a unique identification number (id) by Python interpreter. Identity operators check if id() of two objects is same. 'is not' operator returns true of id() values are different and false if they are same.>>> a=10 >>> b=a >>> id(a), id(b) (490067904, 490067904) >>> a is not b False >>> a=10 >>> b=20 >>> id(a), id(b) (490067904, 490068064) >>> a is not b True

Read More

What does 'in' operator do in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 26-Feb-2020 688 Views

In Python, in and not in operators are called membership operators. Their purpose is to check if an object is a member of a certain sequence object like string, list, or tuple. The in operator returns true if object is present in sequence, false if not found>>> 'p' in 'Tutorialspoint' True >>> 'c' in 'Tutorialspoint' False >>> 10 in range(0,5) False

Read More

How to convert an object x to a string representation in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 24-Feb-2020 303 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 a default and unambiguous representation of the object, where as str() gives an informal representation that may be readable but may not be always unambiguous.>>> str(d) "{'a': 1, 'b': 2, 'c': 3, 'd': 4}" >>> repr(d) "{'a': 1, 'b': 2, 'c': 3, 'd': 4}" >>> repr(L1) '[1, 2, 3, 4]' >>> repr(no) '100'

Read More

How can I do Python Tuple Slicing?

Malhar Lathkar
Malhar Lathkar
Updated on 20-Feb-2020 513 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 last element in slice+1. Resultant slice is also a tuple.>>> T1=(10,50,20,9,40,25,60,30,1,56) >>> T1[2:4] (20, 9)Both operands are optional. If first operand is missing, slice starts from beginning. If second operand is missing, slice goes upto end.>>> T1=(10,50,20,9,40,25,60,30,1,56) >>> T1[6:] (60, 30, 1, 56) >>> T1[:4] (10, 50, 20, 9)

Read More

What are the differences and similarities between tuples and lists in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 20-Feb-2020 1K+ 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] >>> #concatenation >>> L3=L1+L2 >>> L3 [1, 2, 3, 4, 5, 6] >>> #repetition >>> L1*3 [1, 2, 3, 1, 2, 3, 1, 2, 3] >>> #indexing >>> L3[4] 5 >>> #slicing >>> L3[2:4] [3, 4]>>> #tuple operations >>> T1=(1, 2, 3) >>> T2=(4, 5, 6) >>> #concatenation >>> T3=T1+T2 >>> ...

Read More

How to get the second-to-last element of a list in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 20-Feb-2020 26K+ 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

Read More

How can I get last 4 characters of a string in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 20-Feb-2020 3K+ 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. Hence we count beginning of position from end by -4 and if we omit second operand, it will go to end.>>> string = "Thanks. I am fine" >>> string[-4:] 'fine'

Read More

Can we assign a reference to a variable in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 20-Feb-2020 1K+ 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.cout

Read More

How can we unpack a string of integers to complex numbers in Python?

Malhar Lathkar
Malhar Lathkar
Updated on 20-Feb-2020 265 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 in a complex number

Read More
Showing 11–20 of 24 articles
Advertisements