Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code
Showing posts with label PYTHON. Show all posts
Showing posts with label PYTHON. Show all posts

Wednesday

PYTHON TUTORIAL 26 : AND LOGIC

x=5;

y=9;

if x==5 and y<10 : # Both the condition has to be satisfied for getting output

    print 'Logic is correct'

OUTPUT:

Tuesday

PYTHON TUTORIAL 25: MULTIPLE PARAMETER

def nameList(*name):  #*name can take any no. of input

    print name
   
nameList('u','me','we')

OUTPUT:



Monday

PYTHON TUTORIAL 24: DOUBLE PARAMETER

def name(first,second):

    print '%s %s' %( first, second)

name('Hack','Defence')

OUTPUT:

Saturday

PYTHON TUTORIAL 23: HOW TO BUILD FUNCTION

def Introduction(x): # by using "def",the function Introduction is defined
   
    return " Hello " + x

print Introduction("Dipankar")

OUTPUT:

Sunday

Saturday

PYTHON TUTORIAL 21: FOR LOOP

data = {"samsung","sony","nokia","micromax"}

for brand in data:

    print "I am going to buy a "+ brand + " mobile phone"

OUTPUT:


Thursday

PYTHON TUTORIAL 19: OR LOGIC

p=19;

q=67;

if p<20 or q>100 : # only one condition need to be satisfied for getting output

    print ' OR Logic is correct'

OUTPUT:

Tuesday

PYTHON TUTORIAL 17: NESTING STATEMENT

thing = 'animal'

animal = 'cat'

if thing =='animal':

    if animal == 'cat':

        print 'cat is an animal'

    else:

        print 'cat is not an animal'

else:

    print 'No idea about the thing'

OUTPUT:

     

Friday

PYTHON TUTORIAL 16: ELIF & ELSE STATEMENT

x=5;

if x==3:

    print 'ok'

elif x==4:

    print 'Not sure about it'

elif x==5:

    print 'Exactly what i said'

else:

    print 'I am the last option'

OUTPUT:

Sunday

PYTHON TUTORIAL 15: IF STATEMENT

x=5;

if x==5:

    print 'Yes It Is Correct'

OUTPUT:

PYTHON TUTORIAL 14: DICTIONARY

book={'dad':'amitabh','mom':'jaya','son':'abhishek'}

print 'dad name is',book['dad']

print 'mom name is',book['mom']

print 'son name is',book['son']

OUTPUT:




Thursday

PYTHON TUTORIAL 13: JOIN OF STRING

HackDefence=['hi','hello','wassup']

security='hello'

blog=security.join(HackDefence)

print blog



Tuesday

PYTHON TUTORIAL 12: INTRODUCTION TO METHODS

x=[1,2,3,4,5]

x.append(20) # number '20' is added in the end of list

print "After adding '20' to the list,x=",x

print""

DipankarChoudhury = ['hack','defence','security','hack']

y=DipankarChoudhury.count('hack')

print "No of times the word 'hack' present in the list :",y

print""

z=DipankarChoudhury.count('security')

print "No of times the word 'hack' present in the list :",z

print""

print "Good Night And Have a Sweet Dream"





Saturday

PYTHON TUTORIAL 11: SLICING LIST

x=list('motivation')

print "x=",x

print""

x[8:]=list('spiration')

print "x[8:]=",x

print""

x[4:]=list('')

print "x[4:]=",x


Friday

PYTHON TUTORIAL 10: MORE ON LIST FUNCTIONS

numbers=[5,6,7,2,1,9]

print "Length of numbers=",len(numbers)

print "Maximum no in the list=",max(numbers)

print "Minimum no in the list=",min(numbers)

numbers[2]=42 #'7' is replaced by '42'

print "After replacing 'numbers' becomes ",numbers

del numbers[2] #deletes the numbers '42'

print "After deleting '42' from the list, the new 'numbers' is ",numbers





Thursday

PYTHON TUTORIAL 9: MORE ON SEQUENCES

x=[4,5,6]+[7,8,9]

print "[4,5,6]+[7,8,9] =",x

print""

y='Dipankar'+'Choudhury'

print "Dipankar+Choudhury =",y

print""

z='hackdefencesecurity.blogspot.com'*5

print "hackdefencesecurity.blogspot.com*5 = ",z







Wednesday

PYTHON TUTORIAL 8: SLICING

numbers = [0,1,2,3,4,5,6,7,8,9]

print "numbers[3:9]  ->",numbers[3:9] #i.e starting at 3 & ending at 8

print "numbers[4:9]  ->",numbers[4:9]

print "numbers[5:9]  ->",numbers[5:9]

print "numbers[5:]   ->",numbers[5:]

print "numbers[:5]   ->",numbers[:5]

print "numbers[-5:-1]->",numbers[-5:-1]

print "numbers[-5:0] ->",numbers[-5:0]

print "numbers[-5:]  ->",numbers[-5:]

print "numbers[:-5]  ->",numbers[:-5]

print "numbers[:9]   ->",numbers[:9]

print "numbers[:]    ->",numbers[:]





Tuesday

PYTHON TUTORIAL 7: SEQUENCES & LISTS

family = ['mom','dad','bro']

print "List of family using positive index :"

print family[0]

print family[1]

print family[2]

print ""

print "List of family using negative index :"

print family[-3]

print family[-2]

print family[-1]







Related Posts Plugin for WordPress, Blogger...