Simple Python Programs
About Python Programming
Free and open-source — You can freely use and distribute Python, even for commercial use.
Easy to learn — Python has a very simple and elegant syntax. It’s much easier to read and write Python programs compared to other languages like C++, Java, C#.
Portable — You can move Python programs from one platform to another, and run it without any changes
A simple program that displays “Hello, World!”. It’s often used to illustrate the syntax of the language.
Basic HelloWorld Program
# This program prints Hello, world!
print(‘Hello, world!’)
Output
Hello, world!
# Python3 program to add two numbers
num1 = 15
num2 = 12
# Adding two nos
sum = num1 + num2
# printing values
print(“Sum of {0} and {1} is {2}” .format(num1, num2, sum))
Output:
Sum of 15 and 12 is 27
Python Program to Verify if a Number is Odd or Even Example
# Python Program to check if a Number is Odd or Even
number = int(input(“ Please Enter any Integer Value : “))
print(“{0} is an Even Number”.format(number)) if(number % 2 == 0) else print(“{0} is an Odd Number”.format(number))
OutPut:
Please Enter any Integer Value : 19
19 is an Odd Number
Also Read: