- 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
216 Views
The best way is to use not operator on list object. If list is empty it returns true, otherwise false.>>> L1=[] >>> not L1 True >>> L1=[1,2] >>> not L1 FalseAnother method is to check if length of list is zero which means it is empty>>> L1=[] >>> len(L1) 0 >>> L1=[1,2] >>> len(L1) 2
Malhar Lathkar
1K+ Views
Use of indented blocks is an important feature of Python. Indent level of the block is more than previous statements. Hence, if multiple if statements are present in a program in nested fashion, each subsequent indented block will have increasing level of indent.if expr1==True: if expr2==True: ... Read More
Malhar Lathkar
117 Views
Python's for loop executes the body of loop for each object in a collection such as string, list, tuple or dictionary. Its usage is as follows −Examplefor obj in seq: stmt1 stmt2Following code snippet iterates over each number element of the list and prints its squareL1=[1, ... Read More
Malhar Lathkar
116 Views
Python's break keyword is used as decision control statement. It causes the remaining iterations to be abandoned and control of execution goes to next statement after the end of loop. Invariably it is executed conditionally and appears inside if block within a loop.while expr==True: stmt1 ... Read More
Malhar Lathkar
107 Views
Python's continue statement is a loop control statement. It causes starting next iteration of loop after abandoning current iteration. Invariably is is executed conditionally i.e. in if blockwhile expr==True: stmt1 stmt2 if expr2==True: continue stmt3 stmt4However, it ... Read More
Malhar Lathkar
114 Views
The symbols > are defined as left and right shift operators respectively in Python. They are bitwise operators. First operand is a bitwise representation of numeric object and second is the number of positions by which bit formation is desired to be shifted to left or right.The >> a=60 >>> ... Read More
Malhar Lathkar
102 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
Malhar Lathkar
246 Views
In Python, // is defined as floor division operator. It returns integer part of a floating point result of division. For example 10//3 returns 3>>> 10//3 3 >>> 125.5//2.5 50.0 >>> 12.5//1.5 8.0However in case of negative division, returned value is rounded towards negative infinity.>>> -10//3 -4 >>> -73//9 -9
Malhar Lathkar
225 Views
In Python ** is a raised to operator. It returns x raised to y in the expression x**y>>> x=5 >>> y=3 >>> x**y 125^ is a bitwise XOR operator. Taking two bits as operands it returns 1 if one is 1 and other is 0>>> a=10 >>> bin(a) #0001 ... Read More
Malhar Lathkar
1K+ Views
In Python = symbol is defined as assignment operator. It requires one variable on its left and an expression on its right. Value of the expression on right is assigned to variable on left. Expression and name of variable are not interchangeable.>>> a=10 >>> b=20 >>> c=a+b >>> a, b, c ... Read More