Saturday, 13 April 2019

#Example 1: Basic Program for basic data types(int,float,string,complex)
a=10
b=3.14
c="jahab"
d=3+2j
e=None
print(a)
print("a =",a)
print("b =",b)
print("Floating value is : %0.1f"%b)
print("c =",c)
print("d :",d)
print("a : ",a," b :",b)
print("a={},b={}".format(a,b))
---------------------------------------------------------
#Example 2:
a1 = 5
print(a1, "is of type", type(a1))
print(a1, "is Integer number?", isinstance(a1,int))
print(a1, "is Float number?", isinstance(a1,float))

a2 = 2.0
print(a2, "is of type", type(a2))
print(a2, "is floating number?", isinstance(a2,float))

a3 = 1+2j
print(a3, "is of type", type(a3))
print(a3, "is complex number?", isinstance(a3,complex))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note:
------
* type() - type() function to know which class a variable or a value
* isinstance()- isinstance() function to check if an object belongs to a particular class.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Program 1: Add Two Numbers
a=10
b=20
c=a+b
print ("Addition result is : ",c)
print ('Addition result is : ',c)
print ('Addition result is : '+str(c))

#Program 2: Add Two Numbers using input function
a=input("Enter First value :")
b=input("Enter Second value :")
c=int(a)+int(b)
print ("Addition result is : ",c)

#Program 3: Add Two Numbers using input function
a=int(input("Enter First value :"))
b=int(input("Enter Second value :"))
c=a+b
print ("Addition result is : ",c)

#Program 4: Arithmetic Calculations
a=int(input("Enter First Value :"))
b=int(input("Enter Second Value :"))
add=a+b
sub=a-b
mul=a*b
div=a/b
rem=a%b
print ("Addition result is : ",add)
print ("subtraction result is : ",sub)
print ("Multiplication result is : ",mul)
print ("Divide result is : ",div)
print ("Divide result is : %0.2f"%div)
print ("Remainder result is : ",rem)

#Program 5: Simple Interest Calculation
p=float(input("Enter P:"))
n=float(input("Enter N:"))
r=float(input("Enter R:"))
si=p*n*r/100
print ("Simple ins :",si)


#Program 6:  Volume of Cone
r=float(input("Enter r :"))
h=float(input("Enter h :"))
v=(1.0/3.0)*3.14*r*r*h
print ("Cone :%0.2f" %v)

#Program 7:  Volume of Sphere
r=float(input("Enter r :"))
v=(4.0/3.0)*3.14*r*r*r
print ("Sphere :",v)

#Program 8:  Using math function
import math
n=int(input("Enter input :"))
dis=math.sqrt(n)
dis1=math.pow(n,2)
print (dis)
print ('Power ',dis1)
print ('Pi ',math.pi)

#Program 9:  Using math function(cone)
import math
r=float(input("Enter r :"))    #convert string to floating value
h=float(input("Enter h :"))
v=(1.0/3.0)*math.pi*math.pow(r,2)*h
print ("Cone :",v)

#Program 10: swapping two numbers using third variable
a=10
b=20
print("Before swapping")
print("a :",a,"\t b :",b)
t=a
a=b
b=t
print("After swapping")
print("a :",a,"\t b :",b)

#Program 11: swapping two numbers without third variable
a=10
b=20
print("Before swapping")
print("a :",a,"\t b :",b)
a=a+b
b=a-b
a=a-b
print("After swapping")
print("a :",a,"\t b :",b)
===============================================
2) Python Versions
    -------------------
Python 1.0 - 1994
 ...
Python 2.7 - 2010  (Python 2.x)
 ...
Python 2.7.15- May 2018
Python 2.7.16- March 2019

Python 3.7.0 - Jun 2018(Python 3.x)
Python 3.7.3 - Mar 2019
1) Python Basics
     ---------------
*Designed by : Guido van Rossum, Netherland
* Developer  : Python Software Foundation
* First appeared : 1990
* OS          : Cross-platform
* License : Python Software Foundation License & GPL(General Public License)
* Type       : OSS(Open Source Software) - Free download and use
* Filename extensions: .py, .pyc, .pyd, .pyo (prior to 3.5),.pyw, .pyz (since 3.5)
* Website : www.python.org
* Paradigm : multi-paradigm: (object-oriented, functional,procedural)
* Derived From : ABC, Modula-3,C,C++,Algol-68,Small Talk & Unix shell
Python application:
----------------------
1. Console Application(normal programs)
2. Window application(Desktop) - single window
3. webapplication(anywhere anyplace via internet)
4. Scientific application & Maths application
5. Data Analytics & Analysis(compare)
6. 3D Games
7. Database application(Python+Oracle,MsAccess,SQLite,MySQL)
8. Graphics & Animation(tortal (child))
9. GUI Application(Forms)
10. Chart(Pie,Bar)
11. Medical
12. Data Structure(store and receive data)
Python Features:
-------------------
--its support OOPS and general purpose language
--case sensitive language
--Cross Platform(support all OS(windows,UNIX,Linux,Mac)
--OSS(Open source Software) - free download and use
--Portable language(convert one OS to another OS)
--Its consist of Many Predefined functions(Library) and class
--Python allow User Defined function(user can create a own function)
--Type infer language(no need datatype) - auto predict
--Dynamic type system and automatic memory management
void main() Vs. int main(): main is a function with a special characteristic that the program execution always start from main. So the function main needs arguments and a return type. These int and void are its return type. Void means it will not return any value, which is also okay.
The short answer, is because the C++ standard requires main() to return int . As you probably know, the return value from the main() function is used by the runtime library as the exit code for the process. Both Unix and Win32 support the concept of a (small) integer returned from a process after it has finished.

Express.js

 Express.js:- -Express.js was originally created by TJ Holowaychuk in 2010.  -Express.js is a web framework for Node.js. -It is an open-sour...