Introduction
Python is an example of a high-level language. Other high-level languages you might have heard of are C, C++, Perl, and Java. it is much easier to program in a high-level language. Programs written in a high-level language take less time to write. They are shorter and easier to read About python in deeply and installation.
You can download .py files of the following examples that directly execute if you have already installed Python in your Computer.
Download Python LanguageTutorials and give star on GitHub if that files are helpful for you.
Now I want to tell you about Coding Part of Python Programming Language:
- Simple Hello World Program
-
-
- print("Hello World")
-
- input()
Output
Hello World
- Variables
Python programming language have 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:
- name = input("Enter Your Name...")
-
- print("Type",type(name), "\n")
-
- principle = 5000
-
- 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
-
- print("Interest Type...", type(interest) ,"\n")
-
- print("Hello ", name, "!\nInterest is=", interest)
-
- input()
Output
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:
- import math
-
- def 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()
-
- mathfunction()
-
- _simple_()
-
- val=input("Enter Any String...")
-
- parameter(val)
-
- special_parameter('parameter '*5)
-
- val1=input("Enter First Value...")
-
- val2=input("Enter Sscond Value...")
-
- dou_parameter(val1,val2)
-
- input()
Output
Type Conversion Fucntions...
32.53 Converted into int = 32
32 Converted into float = 32.0
32.53 Converted into string = 32.53
Press Enter for next function types
Math Fucntions...
Firstly 'import math'
About imported math file ... <module 'math' (built-in)>
Circumference of Circle is : 4.39822971502571
Area of Circle 1.5393804002589984
Press Enter for see How to Add new Function?
Hello I'm in Now _simple_() function
print(_simple_) show function Location of _simple_ <function _simple_ at 0x027B06F0>
Type(_simple_) show Type of _simple_ <class 'function'>
Enter Any String...NeErAj KuMaR
Parameter is : NeErAj KuMaR
parameter parameter parameter parameter parameter
Enter First Value...NeErAj
Enter Sscond Value...KuMaR
Addition of Value1 & Value2 is : NeErAjKuMaR
So above example show 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:
- 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()
Output
Enter Value...5
X is Positive Number
X is positive Number
X is Positive Number
Enter Value...0
X is Negative Number
X is Zero
Enter Value...-3
X is Negative Number
X 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.