🐍 Pythons learning
PYTHON • DATA SCIENCE • AI

Master Python, Data Science & Machine Learning

#Python #Pandas #NumPy #MachineLearning #Projects
Showing posts with label python trending. Show all posts
Showing posts with label python trending. Show all posts

Sunday, August 30, 2020

how to create two dimensional array in python language

How to create a two-dimensional array in python language:

Welcome everyone, Today we will learn how to create a two-dimensional array in python so let's start:
How do you create a two-dimensional array in Python language?
how to create two dimensional array in python
how to create a two-dimensional array in python


There are different ways to create Numpy arrays in python:

  • Using special library functions
  • Using Numpy functions
  • Conversion from other Python structures like lists
we know that Python provides many ways to create 1-dimensional,2-dimensional lists/arrays.  so let's start to create a 1D array of size N initialized with 1s.
learn Matplotlib for Data Visualization 

Thursday, August 20, 2020

How to remove duplicates from list in python 3

How to remove duplicates from list in python 3 :

Hello friends, In this article we will see How to remove duplicates items or elements from the list in python so Let's start :
How to remove duplicates from list in python 3
How to remove duplicates from list in python 3

There are different way to remove duplicates from list :
  1. Method 1 : Using list comprehension method
  2. Method 2 : Using list comprehension + enumerate() method
  3. Method 3 : Using set() method
  4. Method 4 : Naive method
  5. Method 5 : Using collections.OrderedDict.fromkeys() method

Method 1 : Using list comprehension method

This method has working similar to the Naive method , but small difference is it just a liner shorthand of longer methods done with the help of lists comprehension method.

Tuesday, August 18, 2020

Modulo Operator python-modulus in python

Modulo Operator python-modulus in python

Welcome everyone, Today we will see Modulo Operator python,Modulo Operator python for negative number,How does a modulo operator work?,What is the use of modulo operator?,How do you find modulo?,What is the symbol of modulus operator?
so let's start:
Modulo Operator python
Modulo Operator python

Modulo operator is show by the percent sign (%).
The syntax for Modulo Operator python is :

numx % numy
output:
For example:
11 % 2
output:
1
If any case the divisor result is equal to zero then output show ZeroDivisionError:
11 % 0
output:
ZeroDivisionError: modulo by zero.
The modulo operator also work on floating numbers as arguments:
for example:
4.8 % 1.2
Copy
0.0
Remember % character represents the interpolation operator.(formatting strings)
Examples
modulo operator is used for different purpose like One of the most common use is to check whether a number is even or odd.
If a given number divided by 2 and has no remainder, then this number is even number. Otherwise it is odd.

Monday, August 10, 2020

what are python identifiers with example

what are python identifiers with example : 

An identifier is a simple concept which is used to identify entities. ( i.e. class, variables,  functions,module or other object ) Identifier used to differentiate one entity from another entity. An identifier starts with an underscore (_), letter A to Z or small letter a to z or  simply follow by zero or more letter and digits (0 to 9).

Python identifier simple example :

what are python identifiers
what are python identifiers

In the following example we have to used three variables. 
The name of the variables
  •  rollno.,
  •  _sachin
  • and sachin_samprada are the identifiers.
# Basic examples on identifiers

rollno = 1
print(rollno)

_sachin = 5
print(_x)

sachin_samprada = 143
print(sachin_samprada)

Friday, August 7, 2020

comparison python vs r vs sas vs spss

python  vs r vs sas vs spss :

Welcome everyone, Today we will see comparison between  r vs python vs sas vs spss . So Let's start :
what is Python ?
python  vs r vs sas vs spss
  python  vs r vs sas vs spss

1. python is best languages when learning to code :
If you are beginner to learn coding then mostly Python is your language of choice because It is one of the easy programming language to learn (it read and write like to plain English)

2. Python is heavily used in the IOT sector :
Most popular company use python algorithms platform for there services.

Like
  • Google
  • Youtube
  • Quora 
  • amazon etc. 
Advantages :
Powerful, fully-functional programming language
  1.  Latest availability of library Data science Learning and Machine Learning method
  2. Very easy to automate through scripts
  3. Extremely smart community support 
  4. Visualizations algorithms are easy to create
  5. Professional IDE environments are available
  6. object-oriented, functional and structured concepts
  7. A large number of stable package available
  8. Readable and clean syntax 

Sunday, August 2, 2020

Event handling in python tutorials point

Event handling in python tutorials point


Event handlers is used for change device configuration,restart crashed service.  Event handlers are like as application which is also based on the results of service checks in Monitors. In this article we will see in detailed event handling in python tutorials point .

What is event handler in Python tutorials point?


Event handling class in python, which manage callbacks sender to be executed. It is used as attribute in events-aware class object in python but it does not kept as separate instance.

Event handling decides what should exactly happen if an any one event occur.This process have the code which is called as event handler. you know that Listener python is responsible for generating response to the event during this mechanism hence it is also known as event handler.

Most important function in event handling :

Event handling in python tutorials point
Event handling in python tutorials point
  1. callbacks
  2. sender
  3. add(callback : Callable)
  4. remove(callback : Callable)
  5. __call__(*args) → [ ... ]

Thursday, July 16, 2020

what is list in python with example-Method/index in list

what is list in python with example :

Welcome everyone, today we are going to learn what is list in python?Before going to learn if you want to learn python for free then click on python tutorials point.The most Important thing about a lists is that items of in list not need always be  the same data type.
In this post, we will discuss python is in list.
Definition of Python list :
A list is a data type in which you to store various types data. remember List is a compound data types in  python.
In a  list we can be use integer, float items i.e.different-two data types under a lists.
 In Python the most basic data structures is the sequence. Each elements of a sequence is assigned its positions or index. The first index in python is zero, the second index is increment by one, and so on.
Python also has six built-in type of sequences like as lists and tuples.
There are different operation include indexing,multiplying, slicing, and checking ,adding.

Python is in Lists :

 How to create list in python ?
Creating a lists is very simple by putting different comma-separated value between square bracket.
 For example −
list1 = ['python', 'matlab', 2015, 2020];
list2 = [5, 6, 7, 8, 9 ];
list3 = ["p", "q", "r", "s"]

 Some Basic List Operation:

what is list in python with example-Method/index in list
fig 01)what is list in python with example-Method/index in list

Python Expression
Results
Description
len([1, 2, 3,4])
4
Length
[1, 2, 3] + [4, 5, 6] +[7,8,9]
[1, 2, 3, 4, 5, 6,7,8,9]
Concatenation
['pythonslearning!'] * 2
['pythonslearning!', 'pythonslearning']
Repetition
3 in [1, 2, 3]
True
Membership
for x in [pythonslearning, 2, 3]: print x,
pythonslearning 2 3
Iteration


1. Create a List in Python

In the previous section we see How to create list in Python. Creating a lists is very simple by putting different comma-separated value between square bracket.
# list of floats
num_list = [11.22, 9.9, 68.34, 15.0]
# list of int, float and strings
mix_list = [1.13, 7, 5, "pythonslearning", 100, "love"]
# an empty list
nodata_list = []
 List can have data items of different types or same types . Hence lists comes under compound data types.

2. Accessing the items from a list

Syntax to access the list items:
list_name[index]


Example:
# a list of numbers
numbers = [24, 26, 28, 35, 40, 50]
# prints 24
print(numbers[0])
# prints 35
print(numbers[3])
# prints 50
print(numbers[5])
Output:
24
35
50
Points to Note:
1. The index cannot be a float number.
For example:
# a list of numbers
numbers = [10, 25, 30, 35, 40, 50]
# error
print(numbers[3.0])

Output:
TypeErrors: list indices always be integers not float

# a list of numbers
numbers = [11, 22, 33, 100, 200, 300]
# error
print(numbers[6])
Output:
IndexError: list index out of range

Tuesday, July 14, 2020

Python range() function in python-range of int

Python range() function

Hello everyone, Today we will learn with the help of different example how to use Python’s range() functions. range() function is in built function in python.I t is generatesd the integer number between the  start to the stop integers means it return the object.
It is used when a users also need to perform an action for a  specific numbers of time. The range() functions is used to generate a sequence of number and char..
range() is used in for loop function and  hence, knowledge of same is keys be aspect. 

What Python range() Basics ?

In simple way , range() function allow user to generate a series of number within a given specific range. Depending on how many argument user is passing to the functions in it. user can decided big the difference will be between one numbers and the next format.PYTHON
range() take mainly three arguments this are following :
  • start:  starting integer from which the sequence of integer is to be returned the value.
  • stop: before integer The range of integers end at stop – 1.integer which the sequence of integers is to be returned the values
  • step: value of integer which determine the increments between integer in the sequence

print("Python range() example value:")
print("input numbers from range 0 to 4")
for i in range(4):
print(i, end=', ')


Output:
Python range() example value:
input numbers from range 0 to 6
0, 1, 2, 3

Some range() function syntax and argument in python:

It contains three arguments. Out of this three 2 arguments are start and step are the optional arguments. 
  1. A start argument is a starting numbers of the sequence. it start with lower limit. By default, it starts with 0 number.
  2. A stop argument is an like as uppers limit.The range() doesn’t include this numbers in the result format.
  3. A step argument is a difference between each number in the search resures. The default value of the step is 1and  if it not specified values.

 Some range() function Examples give below:

Let see all the possible probability now. Below are the three value of range() functions.
Example one – Using only one arguments:
# Print first starting 8 numbers using range python function
for i in range(5):
print(i, end=', ')
Output:
0, 1, 2, 3, 4, 5, 6, 7
Only a stop arguments can be passed to range() . So by default, it taken start = 0 and step = 1. Values
Example Two – using two arguments functions(means: start and stop)
# Print integers value within given starting and ending number using range()
for i in range(2, 7):
print(i, end=', ')

Output:
2, 3, 4, 5, 6

Wednesday, July 8, 2020

method vs function python-types of method-class in python

method vs function python :

Welcome to my article, In this article we are going to see What is method vs function  in python.
before going towards this post if you want to learn python for free then click on  python tutorials point.

Difference between Python Methods vs Functions


METHODSFUNCTIONS
Method definition are always present inside the classes.We don not need a class to define a functions.
Method are associated with the object of the classes they belong to.but Function are not associated with any objects.
For method We cannot invoke it is just by its nameWe can invoke a functions just by its name.
Method can operate on the data of the objects they associate with itFunction operate on the data you pass to them as a argument.
Method is dependent on the class they belong to.Function is independent entities in a program.
A methods requires to have ‘self’ as it first arguments.Function do not require any ‘self’ arguments. 

 Java is also an Object Oriented Programming language, but their is no concept of Functions in it. But Python has both concept of Methods and Functions. https://www.python.org/
Hence key differences between Method and Function in Python are explained.
method vs function python-types of method
fig 01) method vs function python-types of method-class in python

A) Python Method
Method are associated with the object of the classes they belong to
A methods requires to have ‘self’ as it first arguments.
It may or may not return any data
A method can easily operate on the data (instance variable) that is contained by the corresponding classes.
Method is dependent on the class they belong to
Method definition are always present inside the classes.

Basic Program for Method in python : 
class class_name 
def method_name () : 
////////////////////////
# method body for code
///////////////////////////////////
Python For User-Defined Method :


class PYTHON : 
def method_python (self): 
print("I am in method_python of PYTHON class. ") 

class_ref = PYTHON() # object of PYTHON class 
class_ref.method_python() 
Output:

 I am in method_python of PYTHON class

JSON Module in Python: Parsing and Writing JSON Data

The json module in Python allows you to encode and decode JSON (JavaScript Object Notation) data. It provides built-in methods for convertin...