Latest
Loading...

Python for Ethical Hacking

Command Prompt

Featured Post

#5 Jarvis

Jarvis      Now we are going to create some functions. With the help of this functions we are going to make our Play music Open website...

Illustrative program for User defined function

Illustrative program for User defined function

 Illustrative program

Note:- Due to some encoding error you have to remove quotation mark and type by yourself.

Exchange the values of two variables


def swap(a,b):
    print("Before swap: n1=",a)
    print("Before swap: n2=",b)
    temp=a
    a=b
    b=temp
    print("After swap: n1=",a)
    print("After swap: n2=",b)
    return
n1=input("Enter first number")
n2=input("Enter second number")
swap(n1,n2)

Circulate the values of n variables

def rotate(list, order):
    for i in range (0,order):
        j = len(list)-1
        while j > 0:
            temp = list[j]
            list[j] = list[j-1]
            list[j-1] = temp
            j = j - 1
        print(i, "rotation" , list)
list = [1,2,3,4,5]
rotate(list, 3)


Distance between two points

import math
def distance(x1,y1,x2,y2):
    dx = x2 - x1
    dy = y2 - y1
    d = dx**2 + dy**2
    result=math.sqrt(d)
    return result
Xc=int(input("Enter Xc"))
Yc=int(input("Enter Yc"))
Xp=int(input("Enter Xp"))
Yp=int(input("Enter Yp"))
print(distance(Xc, Yc, Xp, Yp))

To find leap year


def leapyr(yr):
    if yr%4==0 and yr%100!=0 or yr%400==0:
        print ("Leap year")
    else:
        print ("Not a Leap year")
Year= input("Enter a Year:")
leapyr(Year)





No comments:

Post a Comment