Posts

Showing posts from November, 2017

Java Code

Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems. Software-  IntelliJ IDEA Community Edition 2017.2.6 x64, Java JDK 9. 1. Java Program to print fibonacci series upto nth term. import java.util.Scanner; public class Main { public static void main(String[] args) { int a = 0 , b = 1 , sum = 1 ; Scanner reader = new Scanner(System. in ); // Reading from System.in System. out .println( "Enter a number: " ); int n = reader.nextInt(); reader.close(); for ( int i = 0 ; i < n; i++) { System. out .print( " " +sum); sum = a + b; a = b; b = sum; } } } Output- Enter a number: 6 1 1 2 3 5 8 Process finished with exit code 0 2. Java Program to print ASCII value of Character entered by user. import java.uti

Python Code

Image
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. Python shell can be used in two ways, viz., interactive mode and script mode. Interactive Mode: allows us to interact with OS. When we type Python statement, the interpreter displays the result(s) immediately. Script Mode: In script mode, we type Python program in a file and then use interpreter to execute the content of the file. Working in interactive mode is convenient for beginners and for testing small pieces of code, as one can test them immediately. But for coding of more than few lines, we should always save our code so that it can be modified and reused. Python, in interactive mode, is good enough to learn, experiment or explore, but its only drawback is that we cannot save the statements and have to retype all the statements once again to re-run them.  Software Use-IDLE (Python 3.6.0) Download link of latest version of Python  https://www.python.org/downloads/