Untitled Document
Integers and Floats ( working With Numeric data Type )
1. Program - How to get type of a variable Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program How to get type of a variable  
       
       #We have type() method which tell us the type of variable 
       num1 = 3
       num2 = 4.16

       print(type(num1))
       print(type(num2))

       
2. Program - Basic Arithematic Operators Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Basic Arithematic Operators
       num1 = 3
       num2 = 2

       #Addition
       print( "Addition of {} + {} : {}" .format(num1,num2,num1+num2))

       #Subtraction 
       print( "Subtraction of {} + {} : {}" .format(num1,num2,num1-num2))

       #Multiplication
       print( "Multiplication of {} + {} : {}" .format(num1,num2,num1*num2))

       #Division
       print("Division of {} / {} : {}" .format(num1,num2,num1/num2))

       #Floor Division --> This will print only integer value ; decimal values will not be there 
       print("Division of {} // {} : {}" .format(num1,num2,num1//num2))

       #Exponent 
       print("Exponent of {} ** {} : {}" .format(num1,num2,num1**num2))

       #Modulus --> this will return reminder from divison operation ( Hint : such operator is useful in finding even / odd number )
       print("Remender  {} % {} : {}" .format(num1,num2,num1%num2))
       print("Remender  {} % {} : {}" .format(4,2,4%2))
       
       
3. Program - To Increment Number Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - To Increment Number 
       # Here we will see two approach to increment the Number 
       # Approach - 1
        num=2
        num = num + 1
        print(num) 
       
       # Approach - 2
        num=3
        num += 1
        print(num) 
        num *=2 
        print(num) 
       
4. Program - Few More Operations on Numbers Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Few More Operations on Numbers 
       
       #Chnaging Numbers into absolute value 
       num = -3 
       print("Absolute value of {} is : {} " .format(num,abs(num)))
       
       #Rounding Numbers to nearest interger whole value       
       num=3.75
       print("Nearest Integer value for {} is {}".format(num,round(num)))
       
       #One more way by specifying range 
       num=3.75
       print("Nearest Integer value for {} is {}".format(num,round(num,1)))
       
5. Program - Number Comparison Operator Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Number Comparison Operator
       
        num1 = 3
        num2 = 2 
       
       #Equal-Equal;  == ( Operator )
       
       print( num1 == num2)            
       print("----------------")
       
       #Not Equal ; != ( Operator )    
                 
       print( num1 != num2)
       print("----------------")
       
       #Greater Than ; > ( Operator )
       print( num1 > num2)
       print("----------------")
       
       #Less Than ; < ( Operator )
       print( num1 < num2)
       print("----------------")
       
       # Greater Or Equal ; >= ( Operator )
       print( num1 >= num2)
       print("----------------")
       
       # Less Or Equal ; <= ( Operator )
       print( num1 <= num2)
       print("----------------")
       
       
6. Program - Type Casting Example Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Type Casting Example 
       # Here we will decalre two string variables having integer value and to perform arithematic
       # Operation We need to typecast it to integer data type
       
       x="101"
       y="202"
       print( x + y )     # This will give the Error        
       print(int(x) + int(y))
 
       
Untitled Document