Skip to main content


Showing posts from July, 2020

Get Bug Bounty Course

Thanks for your interest in our course Limited Offer This is a paid course, Rs 10000 ,Rs 1000  for Indian people, 75$ 15$ for international people , 50$ 10$ for Srilankan people Instructions to get course: Indian people can get the course by paying using this UPI id  tamilhacks@ybl  send 1000 Rs to this upi id with subject bug bounty and after payment take a screenshot and send that to email id - you will get the course within 24 hours. (there will be no tax, when paying using upi id)    The above mentioned method is most preferable. if you don't have a upi id app, install phonepe or google pay   app and register there and pay easily  or  pay here using the alternate method to get this course, this link cost 18% gst for the course . (nearly 30-100Rs for tax and other charges here ) After payment you will receive a payment confirmation mail along with a downlink for the course, you can download the course file using that. As for international peopl

37.Python Filter,Map,Reduce

Python Filter:     The python filter() function takes a list as a arguments and filter out the elements in the list based on a function condition and returns the filtered list.Filter takes 2 arguments:function and a sequence and remember to mention the format. syntax: list(filter(function ,sequence)) #you can use tuple,set instead of list Program numbers=[5,7,28,25,40,400,56,78,94,70,100] multiples=list(filter(lambda a:a%5==0,numbers)) print(multiples) Output [5, 25, 40, 400, 70, 100] Python Map:      The python map() can used to update the values in the list.While filters() remove the unwanted element in the list,map() performs some operation to the elements in the list and return the list.Map takes 2 arguments:function and a sequence . syntax: list(map(function ,sequence)) #you can use tuple,set instead of list Program numbers=[5,7,28,25,40,400,56,78,94,70,100] multiples=list(map(lambda a:a+20,numbers)) print(multiples) Output [25, 27, 48, 45, 60, 420, 76, 98, 114, 90, 120] Python Re

36.Python Lambda

Python Lambda:     Usually,we know we define a function with function name,but it is also possible to define a function without a function name.Such functions are known as anonymous functions or Lambda functions.These anonymous functions defined with a  Lambda keyword in python.That is,a lambda function is a small anonymous function.It can take any number of arguments but must have only one expression.For this reason,Lambda functions are used only when we need one expression to calculate the result. For example,consider a simple program to multiply two numbers. Program def multiplication(a,b):     return a*b result=multiplication(26,90) print(result) Output 2340     The above program has only one expression a*b,this can also be made simple by using Lambda/Anonymous function syntax lambda arguments:expression Program k=lambda a,b:a*b result=k(26,90) print(result) Output 2340      Where,k is a variable to store the result of Lambda(anonymous function).a,b are the arguments/parameters.a*b

35.Python Global Variables

Python Global Variables        A function is typically referred as a block of code which allows you to pass data and return data as a result.A function can also have many variables.A variable declared outside the function is known as Global variable and the variable created within the function is known as Local variable.A local variable cannot be used outside the function but a Global variable can be used both inside and outside the function. For example, Program: def myfun():     a=18 #Local variable     print(a) myfun() Output: 18      Here,a variable is created within a function,so it is a local variable.The scope of local variable extends only within the function. If you try to print the local variable outside the function,the program will display error For example, Program: def myfun():     a=18  #Local variable     print(a) myfun() print(a) #Trying to print Local variable Output: 18 NameError: name 'a' is not defined     A global  variable is created outside the function

Python Basic Program-Palindrome

Python Palindrome: Input:a string (Mom) Output:Mom is a palindrome Input:a string (Monk) Output:Monk is not a palindrome Expalanation:    1)The string "Mom" when reversed produces a same word "moM",so it is a palindrome.     2)The string "Monk" when reversed produces a different word"knoM",so it is not a palindrome. Program 1: def palindrome(p):      word=p.lower()      a,*b,c=word      word1=c,*b,a      if list(word)==list(word1):           return "Palindrome"      else:           return "Not a palindrome" word=input("Enter a word:") result=palindrome(word) print(f"{word} is  {result}") Output: Enter a word:Mom Mom is  Palindrome Enter a word:Monk Monk is Not a Palindrome Program 2:using reverse index def palindrome(p):      word=p.lower()      if word==word[::-1]:           return "Palindrome"      else:           return "Not a palindrome" word=input("Enter a word:&quo

13.1 Python eval() and fixed size input

     In python,it is possible to ask the user for input in order to enhance the flexibility.To get the user input ,the input() method is used. However,Python 2.7 uses the raw_input() method. input() method is widely used for standard input operations.  eval()     The eval() function ,as the name indicates is used to evaluate an expression.The argument within the eval function must be a string syntax: eval("expression") Program a="23+67%58-18//24" result=(eval(a)) print(result) Output 32 It is also possible to evaluate an expression from user.For this the eval() is used with input() syntax: eval(input("expression")) Program a=eval(input("enter expression:")) print(a) Output enter expression: 23+67%58-18//24 32 Suppose you need to get only the first character from the user input,you can use index[] . Program a=input("Get a first character:"))[0] print(a) b=input("Get the second character:"))[1] print(b) Output Get a first chara

34.Python type(),id() and constants

Python type()     The type() method is used to return the data type of a particular variable or an element. Syntax: type(variable/element) Program: a=12 print(type(a)) print(type("Tamilhacks")) Output: <class 'int'> <class 'string'>      The variable a is of data type 'a'.The type of "Tamilhacks" is a string. Python id()          The id() method is used to return the address of where  a particular variable or an element is stored. Syntax: id(variable/element) Program: a=12 print(id(a)) Output: 140727592198896      The variable a containing element 12 is stored in the address 140727592198896.This address varies for each system. Program: a=12 print("a:",id(a)) b=a print("b:",id(b)) Output: a:140727592198896 b:140727592198896      Note that,if more than one variable has the same data,they will point to the same address space.Since both a and b has the same element 12,it points to the same address space.Thus python

8.1 Python List Methods

PYTHON LISTS METHODS:     A list is a collection which is ordered and changeable/mutable. Lists are written with square brackets. Lists are very similar to arrays. They can contain any type of variable, and they can contain as many variables as you wish. Lists can also be iterated over in a very simple manner. It can have any number of items and they may be of different types (integer, float, string etc.).  If you have not visited "Python Lists",check out the link below!! Various methods can be used within Lists.Those methods includes: append()     The append() method is used to join the elements to the end of the existing list. syntax: listname.append(elements) Program mylist=[1,2,4,5] mylist.append("TamilHacks") print(mylist) Output [1, 2, 4, 5, 'TamilHacks'] extend()     The extend() method is used to join the elements to the end of the existing list as separate elements. syntax: listname.extend(elements

Python Basic Program-Swapping

Swapping the  Numbers in List: Input=[4,7,5,9] Output=[9,7,5,4] Explanation: The first and the last element in the list is interchanged. Program 1: def swap(mylist):     a=mylist[0]     b=mylist[-1]     mylist[0]=b     mylist[-1]=a     print(mylist) swap([4,7,5,9]) Output: [9,7,5,4] Program 2: def swap(mylist):      mylist[0],mylist[-1]=mylist[-1],mylist[0]      print(mylist) swap([4,5,7,9]) Output: [9,7,5,4] Program 3: def swap(mylist):      a=mylist[0]      mylist[0]=mylist[-1]      mylist[-1]=a      print(mylist) swap([1,5,7,8]) Output: [9,7,5,4] Program 4: def swap(mylist):      first,*middle,third=mylist      mylist=third,*middle,first      print(mylist) swap([1,5,7,8]) Output: [9,7,5,4] Program 5: def swap(mylist):      first,*middle,third=mylist      mylist=third,*middle,first      print(f"List after swapping:{mylist}") mylist=[] count=int(input("enter number of items in list:")) for i in range(count):      myli

Python Basic Program-Count of Vowels in String

Count of Vowels in String Input: any string say,"Tamilhacks" Output:3 Explanation: The string "Tamilhacks" consist of 3 vowels[a,e,i,o,u] Program 1: def noofvowels(a):     count=0     for i in a:         if i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or   i=='A' or i=='E' or            i=='I' or i=='O' or i=='U':             count=count+1     return count          Word=input("Enter string:") noofvowels(Word Output: Enter string:TamilHacks 3 Program 2: def noofvowels(a):     count=0     for i in a:         if i=='a' or i=='e' or i=='i' or i=='o' or i=='u':             count=count+1         elif i=='A' or i=='E' or i=='I' or i=='O' or i=='U':             count=count+1         else:             pass     return count        a=input("Enter string:") noofvowels(a) Output: Enter string:TamilHa

33.Python Polymorphism

Python Polymorphism     Polymorphism is one of the best features of Object oriented Programming.When one object can take multiple forms or multiple behaviors,that object is said to exhibit polymorphism. There are four ways of implementing Polymorphism: 1)Duck typing 2)Method overloading 3)Method  overriding 4)Operator overloading Duck Typing     Duck typing is one of features used in dynamic typing.In duck typing,the type of class /object is not checked,it checks only whether a specified method is present or not.Duck typing is of belief that if a bird walks like a duck,quakes like a duck,then the bird is a duck. In simple words,it does not check the type of the class,it returns the output if specified method is present. Program class Lion:     def feature(self):         print("I have 4 legs") class cat:     def feature(self):         print("cat,also has 4 legs") for obj in Lion(),cat():     obj.feature() Output I have 4 legs cat,also has 4 legs Program class Lion:  

32.Python Super()

Python Super()     The super() is used to access the methods/functions of base class.It is mostly used in multiple inheritance.It returns an object that represents the parent class. Program class Student:      #parent class     def __init__(self):         print("This is a student class") class Marks(Student): #child class inherits Student     pass Sobj=Student() #parent obj Mobj=Marks() #child obj Output This is a student class  This is a student class      Note the programs outputs two print statements.This is because the __init__() in parent class is executed twice ,one with parent object Sobj and other with child object Mobj. We know that whenever an object is created,the __init__() ,otherwise known as constructor is automatically called,so the __init__() method is called for each object created(In this case,two objects)  Program class Student:     #parent class     def __init__(self):         print("This is a student class") class Marks(Student): #child class in

31.Python-Inheritance Types

Types of Inheritance     As we know,Inheritance is one of the feature of OOPS which allows to extend the classes by inheriting the properties and methods from parent class.The types of inheritance are as follows: 1)Single level inheritance 2)Multi level inheritance 3)Multiple inheritance 4)Hierarchical inheritance 5)Hybrid inheritance Single level Inheritance:     In this type of inheritance ,only one child class inherits the properties of a parent class. Syntax: class A:     methods/attributes class B(A):     methods/attributes Program: class School: #parent class     def schoolInfo(self):             print("Welcome to school") class Student(School): #child class     def studentInfo(self):         print("I am student") stu=Student() #child class object stu.schoolInfo() stu.studentInfo() Output: Welcome to school  I am student Multi level Inheritance:     In Multilevel inheritance,a child class inherits the properties of a base class which in turn inherits the prope