Python

  • Python is a scripting programming language.
  • Python is free and easy to learn.
  • Python is powerful object oriented programming
  • Comparable to Perl, Ruby, Scheme, or Java
  • Code can be grouped into modules and packages
  • Applications : Web applications, Automation, Scientific modelling, Big data applications and many more.

 



Python Real time using Applications

The Most Popular Python and Django Websites are listed Below

  • YouTube (python + django)
  • Dropbox (python +django)
  • Google (python +django)
  • Quora (python +django)
  • Instagram (python +django)
  • Spotify (python +django)
  • Reddit (python +django)
  • Yahoo map (python +django)
  • Hibmunk (python +django)

 

 

 



Python interpreter software

Install in windows

Note : tested on windows 10, 64bit with python 3.6.5.

  • Download & Install official python software from this link.
  • Once Installations done, now going to test the first getting started with hello world print sting example.

 

Install Android App

 

Get Start : Hello World Example

  • Open a new file with .py  extension. Ex : Hello-World.py .
  • Then write the Simple code print("ArunEworld") , and save that.
  • Now right click the file Hello-World.py  , you can see Edit with IDLE option. Open your file with that option.
  • Now Click the Run –> Run Module  in tab or click F5  Button.
  • Now another pop will open. that is the output windows the you can see you output or result also can see if any error in your program.
  • This example is a simple and just print the ArunEworld  word in the output screen using print  function.

 



Python IDE

PyCharm IDE

 



 

Install PIP : Install pip using this below link

 



Remember This

  • In c language like don’t need to put  ; Semicolon  command every end of the line. Because Python inter predictor run every line by line also paragraph. Ex print("ArunEworld")  this will execute with out error in python

 



Skip command

  • Single Line Skip :  # (Hash). ExampleA = 0 #A is int Variable
  • Paragraph Skip : """  (Triple Quat). Example""" ArunEworld is a educational organization

 



Python Keyword

Totally 33 Keywords

  • ‘False’,
  • ‘None’,
  • ‘True’,
  • ‘and’,
  • ‘as’,
  • ‘assert’,
  • ‘break’,
  • ‘class’,
  • ‘continue’,
  • ‘def’,
  • ‘del’,
  • ‘elif’,
  • ‘else’,
  • ‘except’,
  • ‘finally’,
  • ‘for’,
  • ‘from’,
  • ‘global’,
  • ‘if’,
  • ‘import’,
  • ‘in’,
  • ‘is’,
  • ‘lambda’,
  • ‘nonlocal’,
  • ‘not’,
  • ‘or’,
  • ‘pass’,
  • ‘raise’,
  • ‘return’,
  • ‘try’,
  • ‘while’,
  • ‘with’,
  • ‘yield’

 

File : Keyword.py

 

 



Python Functions


Print Function

  • Print function returns
  • Example 1 : print the strings with format specifier.

  • Example 2: You don’t need to declare the type of the variable with format spcifier print("ArunEworld")

Print the variables and numbers

 

Print the Strings

 

Error May Come

Error : Missing operator

Error : for above program

 

Error : NameError

  • Code : if run like this print(ArunEworld)then the below error will come.
  • Error : NameError: name 'ArunEworld' is not defined .

 


Input function

FAQ

  • How to make python to wait for a pressed key?
    • To use input() function to wait a  your python application coed
    • Ex : input("Press Enter to continue...")

 


Raw_input Function

  • Notes will add soon.

 



Python Loops


 

if loop

 


While Loop

  • Repeat execute the your program based on the while condition if true.
  • Syntax while expression: statement(s)
    • Expression : True – Any non zero value or false (Any combination condition)
    • Statements : Your application code, Its may be single line of code or  multiple block of code.

Example

  • if the below example print the value 0 to 8 and then exits from while loop

output

 

 


Infinite Loop using while

  • code : while true : print("ArunEworld")
  • output : ArunEworld  print infinite time, printing speed is based on system frequency.

 



Python List

  • 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.
  • Here is an example of how to build a list.

List  : Accessing an index which does not exist generates an exception (an error).

 

 

 



Python Tuples

  • Tuples are listed items, But its can’t edited.


Python Basic Operators

Arithmetic Operators

Modulo Operators

Multiplication Operator

Using Operators with Strings

Python also supports multiplying strings to form a string with a repeating sequence:

Using Operators with Lists

  • Another example

 



User Defined Functions

Function Declaration:

Syntax :

  • Def – Keyword (in python fuctions begin with keyword)
  • FunctionName – Function call name
  • () – Paranthsis
  • parameters – Any input perameters (Ardument replaed with this paranthesis
  • fucntion_docstring – Documentation fucntion of the string (Optional)
  • : – The code start every function
  • function_suite – Code Block
  • return [expression] – return statement of the function. With no arguments as same on.

Note : parameters, return expression and documentation strings are optional

Examples : A sample function named ‘square’ is defined here.

Result

  • def – keyword
  • square(n) : – Square is function Name
  • “Returns square of a given number” – Function Document contains the doc strings, will store in Special variable called “__doc__ “
  • return n**2 – Returns the square value using return statement
  • print(square.__doc__) – Doc string will be stored in special variable “__doc__” associative with function, and it can be access by using “.” Dot operator, as shown in the print statement.
  • print(square(3)) – By calling the square function with in the 3 argument value, The output will be the square of 9
  • print(square(10)) – By calling the square function with in the 100 argument value, The output will be the square of 10 is 100

Note : Any function can be called by passing required arguments inside the parenthesis within after the function name

 

Function call :

  • Function call generally 4 different arguments like Required Arguments, Keyword Arguments, Default Arguments, variable Length Arguments.

Note : Any function can be called by passing required arguments inside the parenthesis within after the function name

Function call type :

A function can be called using the following types of formal arguments

  • Required Arguments
  • Keyword Arguments
  • Default Arguments
  • Variable length Arguments

 

Required Arguments
  • Required arguments are the non keyword arguments

Example

Results

  • In the example “showname” is the function withh two parameters as “name” and “age”.
  • This function is called twise with same non keyword arguments passed in different order.
  • In each of the calls the arguments which associated with paramete it involved which thier defined.
  • Here we observe the different when two calls.

 

Keyword Arguments
  • Keyword arguments is use when function call.
  • Keyword arguments are identified by parameter name.
  • Keyword arguments can be called any order.

Example

Results

 

Default Arguments
  • A default argument is an argument that assumes a default value if a value is not provided in the function call for that arguments.

Example

Results

  • Note : (very Important ) -> python does not allow passing non-keyword arguments after keyword arguments.

 

Variable length Arguments

Example

Result

  • Will Add Soon.

 



File Modes

 



Example-1

 

Example-2

 


pdf2image 0.1.0

 

 



Python Interview Questions

Q : What are the key features of Python

  • Python is interpreted language.
  • Write your code or make your application with python is very easy and fast but running its very slow compared to compiled c programming.
  • Its Dynamically typed : No need to declare variable type. you can do with out error : x=5 , x="ArunEworld"
  • Object Oriented programming like C++, – Allows define classes along with the composition and inheritance.
  • functions are first-class objects – This means that they can be assigned to variables, returned from other functions and passed into functions. Classes are also first class objects
  • Applications : web applications, automation, scientific modelling, big data applications and many more

Q : What is the difference between list and tuples?

  • List : Its listed but can edited.
  • tuples : It’s are listed but can’t edited

 



Reference

if you have any queries call us +918300026060 or WhatsApp Dismiss

0

Your Cart

%d bloggers like this: