Introduction
- Simple Hello World Program
Output
- # Comment
- print("Hello World") # print Hello World on Screen
- input() # Pause Console Screen
Hello World - Variables
Python programming language has the same type of variable declaration conditions, but in this, No One Keyword is used for declaration variables type.Example: int value ;Here int is not used in Python Programming Language for variable declaration.So I’m giving you full example of Variables:Output
- name = input("Enter Your Name...") # Take input from user
- print("Type",type(name), "\n") # print type of 'name' variable
- principle = 5000 # Assign Value to the variable
- print("Amount Type...", type(principle),"\n")
- rate = 10.5
- print("Rate Type...", type(rate) ,"\n")
- time = 3
- print("Time Type...", type(time) ,"\n")
- interest = principle * rate * time / 100 # Calculate Interest
- print("Interest Type...", type(interest) ,"\n")
- print("Hello ", name, "!\nInterest is=", interest)
- input()
Enter Your Name...NeErAj KuMaR Type <class 'str'>Amount Type... <class 'int'>Rate Type... <class 'float'>Time Type... <class 'int'>Interest Type... <class 'float'>Hello NeErAj KuMaR !Interest is= 1575.0 - Functions
I’ll show simple math function and some other functions for performing the task.But when we want to perform some math function task, then ‘Import math’ library in Program.Example:Output
- import math # import Math
- def type_conversion(): # Definition of Function 'type_conversion'
- print("Type Conversion Fucntions...\n")
- print("32.53 Converted into int = ",int(32.53) ,"\n")
- print("32 Converted into float = ",float(32) ,"\n")
- print("32.53 Converted into string = ",str(32.53) ,"\n")
- input("Press Enter for next function types\n\n")
- def mathfunction():
- print("Math Fucntions...\n")
- print("Firstly 'import math' \n")
- print("About imported math file ... ",math ,"\n")
- radius =0.7;
- circumference=2*math.pi*radius
- print("Circumference of Circle is : ",circumference ,"\n")
- area=math.pi*math.pow(radius,2)
- print("Area of Circle",area ,"\n")
- input("Press Enter for see How to Add new Function? \n\n")
- def _simple_():
- print("Hello I'm in Now _simple_() function \n")
- print("print(_simple_)","show function Location of _simple_ ",_simple_ ,"\n")
- print("Type(_simple_)"," show Type of _simple_ ",type(_simple_),"\n\n")
- def parameter(param):
- print("Parameter is : ",param,"\n\n");
- def special_parameter(param):
- print(param, "\n")
- def dou_parameter(value1,value2):
- print("Addition of Value1 & Value2 is : ",value1+value2,"\n\n")
- type_conversion() # calling function 'type_conversion'
- mathfunction()
- _simple_()
- val=input("Enter Any String...")
- parameter(val)
- special_parameter('parameter '*5) # Special Parameter
- val1=input("Enter First Value...")
- val2=input("Enter Sscond Value...")
- dou_parameter(val1,val2)
- input()
Type Conversion Functions...32.53 Converted into int = 3232 Converted into float = 32.032.53 Converted into string = 32.53Press Enter for next function typesMath Functions...Firstly 'import math'About imported math file ... <module 'math' (built-in)>Circumference of Circle is: 4.39822971502571Area of Circle 1.5393804002589984Press Enter for see How to Add new Function?Hello I'm in Now _simple_() functionprint(_simple_) show function Location of _simple_ <function _simple_ at 0x027B06F0>Type(_simple_) show Type of _simple_ <class 'function'>Enter Any String...NeErAj KuMaRParameter is : NeErAj KuMaRparameter parameter parameter parameter parameterEnter First Value...NeErAjEnter Second Value...KuMaRAddition of Value1 & Value2 is : NeErAjKuMaRSo the above example shows some function type and their uses. - Conditionals Statement
In Python Programming Language, we have ”if” conditional statement but it don’t have switch/case in this language. Firstly, switch/case developed but after some time it was rejected.If you want to get full knowledge, read the article on the official website of Python.Example:Output
- def simple(x):
- if(x > 0):
- print("X is Positive Number \n")
- def alternate(x):
- if(x>0):
- print("X is positive Number \n")
- else:
- print("X is Negative Number \n")
- def chained(x):
- if(x==0):
- print("X is Zero \n")
- elif(x>0):
- print("X is Positive Number \n")
- else:
- print("X is Negative Number \n")
- value=input("Enter Value...")
- value=int(value)
- simple(value)
- alternate(value)
- chained(value)
- input()
Enter Value...5X is Positive NumberX is positive NumberX is Positive NumberEnter Value...0X is Negative NumberX is ZeroEnter Value...-3X is Negative NumberX is Negative Number
I’ll be back for another tutorial on Python Programming Language. I hope you will easily understand my code for learning the purpose of Python.

Kameshwar RoyPosted Oct 5, 2015, 5:27 AM
Nice tutorial Thanks Neeraj Kumar
Neeraj KumarPosted Sep 21, 2015, 10:33 AM
Thank you Sumit Joshi
Neeraj KumarPosted Sep 21, 2015, 10:32 AM
Thank you Nilesh Jadav
Neeraj KumarPosted Sep 21, 2015, 10:32 AM
Thank you Karthikeyan K
Sumit JoshiPosted Sep 21, 2015, 3:32 AM
Thanks for sharing..
Nilesh JadavPosted Sep 21, 2015, 1:20 AM
Nice one sir !!
Karthikeyan KPosted Sep 20, 2015, 11:25 PM
Good one...Thanks for sharing
Neeraj KumarPosted Sep 20, 2015, 1:17 PM
thank you Santhakumar Munuswamy
Santhakumar MunuswamyPosted Sep 20, 2015, 12:20 PM
Good Article. Thanks for sharing
Neeraj KumarPosted Sep 19, 2015, 1:07 PM
Thank you Rajeesh Menoth
Neeraj KumarPosted Sep 19, 2015, 1:07 PM
thank you Pankaj Kumar Choudhary
Neeraj KumarPosted Sep 19, 2015, 1:06 PM
Thank you Sibeesh Venu
Rajeesh MenothPosted Sep 19, 2015, 1:01 PM
Good Start..
Pankaj Kumar ChoudharyPosted Sep 19, 2015, 12:10 PM
Nice Start neeraj..................
Sibeesh VenuPosted Sep 19, 2015, 10:47 AM
Nice Share.