Posts

Getting Started with Java ( Java -1 )

Java is nearly an 100% Object Oriented Programming Language. The smallest part of a java program is a function, which is always a part of any class. Some Functions return or doesn't return anything, we give a suitable return type as we give in C/C++/Python. The syntax is as below : When a function is written within a class we call it a method of that class. The name of the classes in Java are generally written in Capital letters as syntax. All the classes and method in Java has an access modifier. This access modifier determines if any user can access the method or class. Public, private, protected are some access specifier/ accees moderator. The outer class should always be Public or Default ( by not writing any class ). Here is the first program that prints "Hello World".

Pass and Continue Function in Python 3

Pass and Continue Function in Python 3 The pass function is to similar to continue function. But it doesn't take the loop to the next iteration rather is continues through all the conditions given and then goes on to the next iteration. A simple code can sum up the operation of pass function.  An example of the use of Pass Function An example of the use of Continue Function

If __name__ == '__main__' in Python 3

Image
What does If __name__ == '__main__' mean in Python ? As we know that in Python we don't have a definite main functions, we don't require it normally in a program as most programs run flawlessly. But when we are working on more than one python program files and we want to import a certain function of Python_Project 1 in Python_project 2, then  we have to declare the main function as    If __name__ == '__main__'  because if we don't do it the whole main program will run along the function we wanted to run from  Python_Project 1  in  Python_project 2.  Like in C, C++ we use a main function similarly it is a type of main function which is used when required.  We require two python files to see it's proper execution. We get the output as 10 in Project 2. See Project 1 and Project 2 we are using add function from Project 1 in Project 2 through normal importing, but we have declaired the main here. If we haven't ...

Try / Except / Else / Finally Functions in Python 3

Error Handling in Python 3 When you run a program, there are time when you experience a runtime error. These are experienced because the input might not be appropriate according to a data type or file which you may be opening does not exit or some math error occurs ( there can be several other reason for runtime errors). But the Try function in Python lets us to properly manage the error through error handling. Try keyword and except keyword are complementary to each other. If any runtime error is experienced while running the Try block the Except block is runs, where you can five a customised error message or you can even writing another alternate piece of code.

Python 3 Operators

Image
...<< Python Operators > >... Operators are used to perform operations on variables and values. Python divides the operators in the following groups: Arithmetic operators Assignment operators Comparison operators Logical operators Identity operators Membership operators Bitwise operators Python Arithmetic Operators Arithmetic operators are used with numeric values to perform common mathematical operations: Operator Name Example Try it + Addition x + y Try it » - Subtraction x - y Try it » * Multiplication x * y Try it » / Division x / y Try it » % Modulus x % y Try it » ** Exponentiation x ** y Try it » // Floor division x // y Try it » Python Assignment Operators Assignment operators are used to assign values to variables: Operator Example Same As Try it = x = 5 x = 5 Try it » += x += 3 x = x + 3 Try it » -= x -= 3 x = x - 3 Try it » *= x *= 3 x = x * 3 Try it » /= x /= 3 x = x / 3 Try it » %= x %= 3 x = x % 3 Try it » //= x ...

Exit () and Quit () Function in Python 3

Exit and Quit both are used to get out of a program which is running. he  exit  and  quit  "functions" are actually  site.Quitter  objects and are loaded, at interpreter start up, from  site.py . However, if the interpreter is started with the  -S  flag, or a custom  site.py  is used then  exit  and  quit  may not be present. Recommendation Replace uses of  exit()  and  quit()  with  sys.exit()  which is built into the interpreter and is guaranteed to be present. Example In this example,  exit()  is used and will fail if the interpreter is passed the  -S  optio n. 1 2 3 4 5 6 def   main():      try :          process()      except   Exception as ex:          print (ex)    ...