Python

PyCharm IDE

 


 

Install PIP : Install pip using this below link

  • https://bootstrap.pypa.io/get-pip.py

Skip word

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

Hello World

Print the hello world Example :  print("ArunEworld") or

Print the variables and numbers

  • Numbers

  • String

  • But This is not working : Missing operator

Error : for above program

 


Python Keywords (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

 

 


if loop

 

How to make python to wait for a pressed key

  • input("Press Enter to continue...")

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).

 

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

 


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