- Trending Categories
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
Found 34489 Articles for Programming
![V Jyothi](https://www.tutorialspoint.com/assets/profiles/13530/profile/60_77592-1512648869.jpg)
202 Views
The operator keyword declares a function specifying what operator-symbol means that once applied to instances of a class. this gives the operator more than one meaning, or "overloads" it. The compiler distinguishes between the different meanings of an operator by examining the types of its operands.The unary operators operate on a single operand and following are the examples of Unary operators −The increment (++) and decrement (--) operators.The unary minus (-) operator.The logical not (!) operator.The unary operators operate on the object for which they were called and normally, this operator appears on the left side of the object, as ... Read More
![Nikitha N](https://www.tutorialspoint.com/assets/profiles/13558/profile/60_76068-1512713229.jpg)
6K+ Views
The operator keyword declares a function specifying what operator-symbol means when applied to instances of a class. This gives the operator more than one meaning, or "overloads" it. The compiler distinguishes between the different meanings of an operator by examining the types of its operands.The unary operators operate on a single operand and following are the examples of Unary operators −The increment (++) and decrement (--) operators.The unary minus (-) operator.The logical not (!) operator.The unary operators operate on the object for which they were called and normally, this operator appears on the left side of the object, as in ... Read More
![V Jyothi](https://www.tutorialspoint.com/assets/profiles/13530/profile/60_77592-1512648869.jpg)
7K+ Views
Whitespace is a term that refers to characters that are used for formatting purposes. In C++, this refers primarily to spaces, tabs, and (sometimes) newlines. The C++ compiler generally ignores whitespace, with a few minor exceptions. For example, all the 4 lines below mean the same thing −cout
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
5K+ Views
A prime number is the one that is not divisible by any other number except 1 and itself.In Python % modulo operator is available to test if a number is divisible by other. Assuming we have to find prime numbers between 1 to 100, each number (let us say x) in the range needs to be successively checked for divisibility by 2 to x-1. This is achieved by employing two nested loops.for x in range(1,101): for y in range(2,x): if x%y==0:break else: print (x,sep=' ', end=' ')Above code generates prime numbers between 1-1001 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
322 Views
Any loop is formed to execute a certain number of times or until a certain condition is satisfied. However, if the condition doesn't arise, loop keeps repeating infinitely. Such an infinite loop needs to be forcibly stopped by generating keyboard interrupt. Pressing ctrl-C stops execution of infinite loop>>> while True: print ('hello') hello hello hello hello hello hello Traceback (most recent call last): File "", line 2, in print ('hello') KeyboardInterrupt
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
168 Views
The else block in a loop (for as well as while) executes after all iterations of loop are completed and before the program flow exits the loop body. The syntax is as follows −Syntaxwhile expr==True: #statements to be iterated while expr is true. else: #this statement(s) will be executed afteriterations are over#this will be executed after the program leaves loop bodyexamplefor x in range(6): print (x) else: print ("else block of loop") print ("loop is over")OutputThe output is as shown below −0 1 2 3 4 5 else block of loop loop is over
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
248 Views
Python doesn't have an equivalent of do-while loop as in C/C++ or Java. The essence of do-while loop is that the looping condition is verified at the end of looping body. This feature can be emulated by following Python code −Examplecondition=True x=0 while condition==True: x=x+1 print (x) if x>=5: condition=FalseOutputThe output is as follows −1 2 3 4 5
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
970 Views
PEP 315 (Python Enhancement Proposal) to include do..while statement has been rejected because it doen't fit in the general format of indented block statement: indented block used by every other Python compound statement. In words of Guido Van Rossum - "Please reject the PEP. More variations along these lines won't make the language more elegant or easier to learn. They'd just save a few hasty folks some typing while making others who have to read/maintain their code wonder what it means".
![Gireesha Devara](https://www.tutorialspoint.com/assets/profiles/397483/profile/60_1063327-1637125522.jpg)
2K+ Views
In Python normally for loops are constructed to iterate over a block for each item in a range. If a premature termination of loop is sought before all iterations are completed, then we can use break keyword. It is invariably used in a conditional statement inside the body of a loop. Using the break statement Let’s take a few examples to see how the break statement works on for loops. Example In this example the for loop is defined to iterate upto 20 loops, but the break statement terminates the for loop at 10th iteration i.e., x=10. If we ... Read More