Skip to main content

Posts

Showing posts from September, 2017

Python #12-Recursion functions in Python

Previous post:                                                                                                                                     Next post: Python #11-Functions in Python                            Python #13-Let's Play with Python part-1-Fibonacci Series What is recursive function? A recursive function is a function which is called by itself.. Example: def decreasingorder(num):   if num==0:      print "values is Zero"   else:      print num      decreasingorder(num-1) decreasingorder(2)                                                #calling function with argument 2  Here decreasing order is the recursive function. I have called the function inside the same function. Inside the else. I have called the decreasing order function to perform the operation. Program Explanation: First of the Input to the function should be passed. For eg: I have passing (2) to the decreasingorder function. It will check whether given number

Python #11-Functions in Python

Previous post:                                                                                                                                     Next Post: Python #10-Dictionaries in Python                               Python #12-Recursion functions in python what are functions? functions are the set of programs instructions that perform a specific task. Syntax:     def functionName(arguments):            statements Note Worthy: def is the keyword in python which is used to define a function in python. Example:     Let me create a function to add two number and print the output... Source code:     def add(a, b):         print a+b     add(1, 2) Output:      3 Note: Use the 🖉 for code editor. Use the▶ to view the output. Explanation: #Line 1: def add(a,b) :                 This line is used to declare a functions with an arguments a and b. #Line 2: print a+b                 This is the print statement inside the add() which also perform a+

Python #10-Dictionaries in Python

Previous post:                                                                                                                                      Next Post: Python #9-Set Operation in Python                                                                          Python #11- Functions in Python What are Dictionaries in Python? Dictionaries is an unordered collection  of  key value pairs. How the dictionaries will look? A dictionaries hold the key and values inside the curly braces where as key and values are separated by colon : operator.. Syntax: VariableName={' key1 ' : ' value1 ', ' key2 ' : ' value2 ', .....' keyN ' : ' valueN ' } Note Worthy: In Python dictionaries will be created by means of the Curly braces { } consists of key and values inside in it eg: {'key' : 'values'} Example: Note: Use the 🖉 to see code editor. Use the ▶ view the output . Explanation: #line 1 :   phones

Python #9-Set Operations in Python

Previous Post:                                                                                                                                     Next Post: Python #8-Sets in Python                                                                              Python #10-Dictionaries in Python What are set operations ? Set operations is defined as  performing operation with two data sets for finding  comparing, intersections of the elements . Set operations are performed by set operators.... Union: Union of A and B is the set of all things that are members of A and B. Try it 1: Intersection: Intersection is the set of all things that intersect with A and B. Try it 2: Difference (A-B): Difference is the set of all elements in A and not in B.   Try it 3: Difference (B-A): Difference is the set of all elements in B and not in A. Try it 4: Symmetric Difference: Symmetric Difference is the set of elements which are either are in sets but

Python #8-Sets in Python

previous...                                                                                                                                              next....           Python #7-Class and Objects in Python                                 Python #9-Set Operations in Python What are sets in python? A set is an unordered collection with no duplicate elements. How to create set?  Use { , , ,  } - To create a set Syntax:     SetVariableName = {SetValues1, SetValues2, ..... } Example: Note Worthy: Set are Created by means elements inside the { , , , } are considers as set. Braces with no elements { } are consider as an empty dictionary. .... Set with Duplicate Elements get eliminated automatically. Try it.... Pros: This is the Advantage of using the set in the Python Programming.. ********* You can able to perform add, delete, update in set. ************ Example: Try the adding elements to the set.. Note: Set does not allow repetition of e

Python #7-Class and Objects in Python

cont....          of Python #6- Keyword in Python What is Class ? A class is a collections of objects. It is also called as grouping of data and functions. Syntax:    class className():        def methodName1(self):             statement        def methodaName(self):              statement Example:  Explanation:     As we know Python follows indentation. The spacing for the lines should be strictly followed to avoid any errors. #line 1:  It consists of the class name cname(): #line 2: def add(self):                This line allows you to create a function or method in python. Note Worthy: "self" is built in parameter constant which takes its own parameters if does not any parameters or arguments are supplied. #line 3: It is the normal print statement which is inside the Add() function. #line 4: def sub(self):                 This is again another method which print "Subtraction" ones this method is invoked. #line 7: def

Python #6-Keywords in Python

cont....           of Python #5 - Variables and Strings in Python What are Keywords? Keywords are the reserved for special purpose. It can't be used as variables name or identifiers. Keywords in Python: False          class           finally          is          return          None          for continue    lambda      try               True      def               from          while nonlocal    and             del              global   not               with           as elif             if                 or                yield      assert          else             pass import       break          except         in           raise Brief of Keywords: _________________________________________________________________________________ True , False :  It is used for the comparison operations or logical operations. Example:      >>> 10 == 10      True      >>> 10 > 20      False ___________________________________

Python #5-Variables and Strings In Python

cont....       of    Python#4-If and elif Statements in Python What are variables? A variable is the one which holds the values. Syntax :     VariableName = values Example:     variable = 1     print variable Output:     1 Integer Variable can be used like this in python...eg: variable =1 Note Worthy: Like C, C++, Java you don't have to declare the data type of the variable in python. The variable in Python is itself acts as datatype based on the values it holds.  How to store the Strings in variables? Its the same as the Integer Variable usage, but the minor change is .... The String should be surrounded with quotes .. Syntax:     StringVariableName = "String values goes here" Example:     String="Dharani"    print String Output:     Dharani Note Worthy: Some times you might get a doubt that...whether we should ' '  or " " for string .Chill!...No worries in Python..You can use both..It works.. Try Yours

Python #4-If and elif statements In Python

cont.....          of   Python #3-For Loop and While Loop In Python What is if Statement? An if statement is Selection statement. It is also called as Decision Making Statement. Syntax:       if (condition):          statement Example:      marks = 39      if marks < 40 :         print "failed" Output:      failed Note Worthy: As i said previously Python uses indentation to make code blocks. So the statement should me done as it is in the above syntax. _________________________________________________________________________________ Don't forget to try here! ____________________________________________________________________________ if else: Syntax:       if (condition):          statement      else:          statement Example:       marks = 41      if marks < 40 :         print "failed"      else         print "passed" Output:       passed ___________________________________

Python #3-For Loop and While Loop In Python

cont.....          Of  Python #2-Tuples and List In Python what is For Loop ?  A statement which makes the code to executed repeatedly. Unlike in C,  C++, Java  For looping has the same syntax, but in Python its Different. Syntax:     for TemporaryVariableName in ActualVariableName :           statement Example:     values=['value1', 'value2', 'value3']         for value in values:        print value  Ouput:    Value1    Value2    Valus3 Note Worthy: for statement should have : at the end of the line in python          eg:  for(condition):   _____________________________________________________________ Don't forget to Try it! _____________________________________________________________ What is while Loop? A statement which makes the code to executed repeatedly as of the repeated if statement Unlike in C, C++, Java While looping has the same syntax , but in Python its with Slight Different. Syntax:

Python #2-Tuples and List In Python

cont......          Of Python #1- A way to start with Python what is Tuples ?  A tuples is sequence of elements .Immutable ordered Sequence. What is Immutable? You can not able to change the values once its is declared or Initialized . Syntax:     TupleVariableName = somevalues1, somevalues2,... Note Worthy : A comma is Tuple create Operator in Python. Example :     TuplesVariableName = 1, 2, 3     print (TuplesVariableName) Output:     (1, 2 ,3) To find the Length of the Tuple? Syntax:     len ( TuplesVariableName )                   #len is the keyword to find the Length Example:    print  len ( TuplesVarableName ) Output:     3 _________________________________________________________________________________ *In case if you want to print the particular tuple values Syntax:     TupleVariableName [IndexValuesYouNeeded ] Example:     TuplesVariableName [2] Output:     3 _________________________________________________________________

Python #1-A way to start Python

Hai , Here is my blog which i learn from the google i used to post in this space.. so there might be some contents will taken from other source too as a part of learning. The learn will be made Easy here. If you like and Need to learn like this more.. Do Follow...#Tech Bird Lets Start with Python.! Example 1:  How to Write "Hello World !" in python  It is much simpler than other programming languages.Yup! Syntax:          print "Statement" Example:         print "Hello World!" Output:        Hello World Note Worthy: In python there is no need to place a ; once the statement is ended. Example 2: How to add two numbers in Python. Its is as such as simple maths problem..Yup! Example:     a=10     b=10     c     c=a+b     print "c values is: "+c Output:     c values is : 20 Note Worthy: In python you don't have to define the type of variable you are using like java or c.. For eg: in java int a=10, i

How to use command line arugments in c

Hi its me Dharani again with a blog ... About : " how to use command line arugments in c" Requirements : " Gcc compiler installed and Cmd(command prompt)" ****I will be using SublimeText3 for coding no worries you do those stuff with notepad itself***** Note: Gcc is used to compile the program bcz cmd does not know any programming languages.. Cmd acts as console to compile and run the program ... Cool..! Lets get Started.. Hoping Gcc has been installed on your system. First you need a Piece of code to start with.. //MyFirstProgram.----C program to print all arguments given through command line. Source code: #include<stdio.h> void main(int argc, char const *argv[]) { /* code */ int a,b,c;     printf("Enter the Three Values:"); scanf("%d %d %d",&a,&b,&c); printf("Values in the arguments: \n a is %d b is %d c is %d", a,b,c); } Save this code in Notepad File and save as .. some

Getting Started with Python

Python  Python is an object-oriented programming language created by Guido Rossum in 1989.  It is ideally designed for rapid prototyping of complex applications.  It has interfaces to many OS system calls and libraries and is extensible to C or C++.  Many large companies use the Python programming language include NASA, Google, YouTube, BitTorrent, etc. Python had deep focus on code readability .. Advantages: Extensive Support Libraries Integration Feature Improved Programmer’s Productivity Productivity Python used in Artificial Intelligence,  Natural Language Generation,  Neural Networks and other advanced fields of Computer Science. Simple Program using Python. Example: print "hello world!" Output: hello world Thank You👍😍! Come Back to Learn More From Tech  Bird 😜✌👻😍