# Trending December 2023 # A Comprehensive List Of The Different Python Data Types # Suggested January 2024 # Top 17 Popular

You are reading the article A Comprehensive List Of The Different Python Data Types updated in December 2023 on the website Katfastfood.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 A Comprehensive List Of The Different Python Data Types

Introduction

Python is one of the most preferred programming languages these days. It allows developers to focus all their efforts on implementation instead of complex programs and data types in python are used for that purpose only to make our work easy.

Overview of the Different Data Types

The classification or categorization of data items is known as Data types. A kind of value is signified by data type which determines what operations need to be performed on that particular data.

It is used for integral values. In python 2 versions, there was different Int and long for small and big integral values, but from python 3 it is int only.

We can represent int in 4 forms.

Decimal form ( it is by default and digits are from 0-9)

Binary form (base-2, 0, and 1)a=1111, so if do print (a)It will be a normal chúng tôi to convert it into binary, we make a change like a=0B1111So basically zero(0) small “ b” or zero(0) capital” B” is used in prefix.

Octal form (0-7 )So in this zero(0) and capital “0” or small “o” is used in prefix.

Hexadecimal (0-9, A-F)In this zero(0) and small or capital “x” is used.

Now the thing to remember is by default the answer we will get will be in decimal forms, so we can change that as well.

Float:

Float is a data type in which decimal values are there. In float, we can only have decimal no binary, oct, or hex. Eg: a=15.5 So when we see the type of “a” It will be float type.

Complex :

Print (type(x)) #so it will be complex

The real part can be binary, octal, or hex anything, but the image should be decimal only.

We can type real part in any form like binary octal or hexadecimal but not for imaginary

OB111 + 20j  it is correct. But 14+ 0B101   it is incorrect

So we can do x+y, we can do x*y  or we can do x/y  or x-y

So addition or subtraction of the complex numbers is simple. We simply do addition or subtraction of the real part of both numbers and imaginary parts of both numbers.

(a+bi)  * (c+di)   = (ac-bd) + (ad+bc)i

So whenever we multiply two complex numbers the answer we will get is by this formulae Or we have actually simplified the formula.

Simply let’s say we take two complex numbers.

a= (2 + 4j)       ,      b=  (10 + 10 j)

So now when we multiply them It will be multiplied like this-– 2 (10 + 10j) + 4j(10+10j)

– 20 + 20j  + 40j + 40j^2

And we know ^2 of imaginary part is -1. So it will become-

-20 + 60j

a= p+qj

b= r+sj

So division would be

a/b  =   pr + qs     +    qr – ps      ,  x= under root of (r^2 + s^2)

———          ——–

X                    x

This complex is used much in machine learning or mathematics specific queries.

Boolean

But one thing is to remember that the first letters should be in the capital True, False

a=True Type (a)

It will show bool

So let’s take an example.

﻿

it will show false

The type would be

Print (type(c))

Bool

Now one more thing to remember is True =1 and False =0

So if we print (True + True)

The answer would be 2 (1+1)

And if we print (True-False) The answer would be 1  (1-0)

Strings

So in string data type, we can use single, double, or triple quotes. So for eg: S= ”Aashish”

S=’Aashish’

We can print type(s) it will give us string

Also s = ”a”

It will also give string unlike java etc because in java etc it must have given it as a character. but there is no data type as a character in python

Now comes the triple quotes. If we have to write the string in multiple lines, then we cannot use single or double quotes, what we can use is single triple quotes or double triple quotes

Like eg :

Aashish’’’

Or

Aashish”””

One more thing we need to know now is the let say we have one statement. Like-

s= Aashish is a very ‘good’ boy

Now in the above statement if we want that Good should be in quotes, so while writing the string we should know that the statement should not be in single quotes. Like-

“Aashish is a very ‘good’ boy”.

And the same goes if we want something in double-quotes, then we have to make the whole statement in a single quote. Now if we want to use both single and double quotes in a statement.

“Aashish” is a very ‘good’ boy

Then we have to put the whole statement in triple quotes.

Positive and Negative Index in strings

So there is indexing in python string, so if let say we want to access the character of the word for eg: from a=  Aashish, we want to access “i”

So we can do it like-

Print (a[4])

The first alphabet is represented by 0. Also, we can do like in python a[-1], which represents the last character.

So it will print h

Slice Operator in String: basically it’s a part of the string which is known as a slice. So to fetch that slice we use it.

Eg:  “Aashish”

In slicing let say we want only “shis”

format is s[begin : end]

Which returns from beginning to end-1. So if let’s say put s[2:6]. It will return to the 5th. Now if we are not specifying begin. Then it will start at 0 s[:5].

If are not specifying it will continue to the end s[2:]. And one case is s[:]. It will return the total string.

One more case s[5:2]. We will get an empty string, as it cannot move from 5 to 2.

And we want the output as “Aashish”

So we can do it like.

output= s[0].upper() + s[1:] print(output)

So we can do it like

output = s[0:len(s)-1]  + s[-1].upper() Print (output)

Now let’s say we need to have the first character in the capital and the last character in the capital and remaining as it is. So what we need to do is simply :

Output = s[0].upper() + s[1:len(s)-1] + s[-1].upper() Print (output )

And * operator for string data type :

Is used for concatenation, and both the arguments should be string only.

So  it can be “String” + “String” + “string” + …..

It cannot be like “String” + “Int”

Now * operator

s=”SUN” *3

So it is a string repetition operator. And used to multiply the string. One thing to notice here is one argument should be a string and the other should be an integer

TypeCasting

The process of converting from one type to another type. 5 inbuilt functions are there-

Int

Float

Complex

bool()

str()

Int: To convert from other types to the int type

Float to the int function, so like if we have 10.989 is there, so after the decimal point all digits will be gone so it will be done like int(10.989), it will give 10.

Complex to int: 10+ 20j, so int (10+20j), it will give type error, as we cannot convert complex to int type.

Bool to int:  int (True)   will give 1

String to int :String internally contains an only integral value or in base 10 only, so no hexadecimal or binary, etc.Therefore int(“15”)  will give chúng tôi (0B1111) will give an error

int(“10.5”) , again error as it is not integral value it is a float value.

Float: Convert into the float type

Or Float(0XFace) will give 64206.0

Complex to float is not possible :

float(False), then the answer would be 0.0

String to float type is also possible, only in the case when the string contains an integral value or float value but they should be specified in base 10.

Float (10)  will give 10.0

Float (0XFACE)  error

Float (“Aashish”) error

Complex Type

Complex (x)

If only one argument then it will become a real value

Complex (10)

The answer would be 10 + 0j

Complex (0B1111)  would be 15+0j

Complex (10.5) would be 10.5 + 0j

Complex (True) would be 1+0j

Complex (False) would be 0j

Complex (“String”) it should have either int or float value in base 10

Complex (x,y)

When two arguments are there one will go to real and one to the imaginary complex(10, 20) would be 10+20j.

Complex (10.5, 20.6) would be 10.5 + 20.6j

Complex (“10”, “20”)

It will give an error if we are having the string argument, we can’t have the second value as a string as well

Complex (10, “20”)

It will also give an error, the second argument can’t be a string in complex

Bool()

bool(10)

If it is non zero then it will be True

bool(10) will give True

bool(0) will give false

Float

bool(0.1) true

bool(0+0j)    False

bool(1+0j)  True

String

bool(“True”)   True

bool(“False”)   True

bool(“Yes”)  True

bool (“No”)   True

bool( “ ”)   False

If the string is empty then only it is false, otherwise if it not empty then it will be True

String

str(10)  “10”

str(0B1111) “15”

str(10.5)    “10.5”

str(10+20j)  “10+20j”

str(True)   “True”

str(False)  “False”

Fundamental Data Types vs Immutability

Immutable → we cannot change

Once we create an object, we cannot perform any changes in that object. If we try to change, then the new object would be created. This non-changeable behavior is immutability.

Python Data Type: Lists

These are the collection related data type.

l=[07, “Aashish”, 20,30, “Nimish”] Print type(l)

It will give a list. The list is always in square brackets. If we print (l), the order will be in the same in which we have given. So the order of perseverance is there. Duplicates objects are allowed.

Heterogenous objects are allowed, like int, string, etc. Indexing and slicing are applicable. Now,

print (l[0])

So will give the first element. And similarly -1 for the last. Now if let say we have an empty list.

l=[  ]

So we can add elements like-

l.append(10)

We can remove elements like-

l.remove(10)

Now let say, we have-

l=[10, 20, 30, 40]

Now the list is mutable so at l[0] we can add value. Like-

l[0]= 100

So now 100 will be added to the starting. List will become l[100, 10, 20, 30, 40].

Python Data Type: Tuple

Now we will learn the data type Tuple. It is the same as the list except it is immutable, if we create one object so we cannot add or remove any object or value. It is like a read-only version of a list. We represent tuple by (10, 20,”aashish”).

Performance is better than the list. And it also uses less memory than a list.

Python Data Type: Set

Now we will learn about the new data type i.e Set. It is used for the group of objects or entities but duplicates are not allowed and I don’t care about the order. So if we have such a type of requirement then we go for the Set.

So-

s1 = {1,2,3} s2 = {3,1,2}

So basically s1 and s2 are equal. So in the set, there is no first element no last element kind of concept. Curly brackets are used inset.

s= {10, 10, 20, “Aashish”, 30}

But output will come s= {10, 20, “Aashish”, 30}

But order can be anything. So indexing cannot be there or slice operator-

Print s[0]

Will give an error.

Heterogeneous objects are allowed.

In the list, it was appended. In set, it is added.

Append was used in the list to add items in the last. So add is used in the set, as we don’t know where it is going to get added.

s= {   }

So it is not known as an empty set it is known as an empty dictionary. As the dictionary gets privilege because of the frequent use of it more than the set.

If we want to create the empty set then we can create it like

s= set() Python Data Type: Frozen set

It is exactly like a set except it is immutable. Because inset we can make changes, but not in the frozen set. So we create the frozen set like-

s={ 10, 20, 30, 40} fr= frozenset(s) Print type(fr)

It will be frozen set s.

So now we cannot add or remove the values from the frozen set and will get the attribute error if we try to do that.

Python Data Type: Range

Now we will learn about the Range.

R = range(10)

So we will get 10 values starting from the 0. So basically it is an inbuilt function used in python. If we print r-

It will give 0,1,2,3,4,5,6,7,8,9

We can use it like

For x in r :    print(x)

So we will get all the values printed. How we can make the range objects.

Form:   range (n)

So will give values to 0 to n-1

Form :  range(begin : end)

So will give values from the beginning to the n-1

r= range(1, 10) For x in r :     Print (x)

So we will get 1,2,3 ….  9

Form:

Range (begin, end, increment/Decrement)

R = range(1,21,1) So 1 to 20

1,2,3,….. 20

R = Range(1, 21,2 )

1,3,5… 19

Also, we can do like for decrement

Range (20, 1, -2)

So 20, 18 ….

So now we have known things go in order in range, so wherever order is there, we can do the indexing or slicing. But the range is immutable, as the values are in sequence and if we try to add the values, an error will occur.

Python Data Type: Dict

Now we will learn about the dictionary. Dictionary is different from the above data types in the manner that it is used to represent the key values.  Represent by Dict

d={ k1: v1, k2 : V2}

So let say we have an empty dictionary

d= {   }

So we can add value like

d[100]=”Aashish” d[200]= “Ayush”

So it will look like-

{ 100 : Aashish , 200 : Ayush}

Now there would be one concern about the duplicity of the values. So duplicate keys are not allowed but values can be duplicated. S-

d[100]  = “Abhishek”

So the old value i.e Aashish will be replaced by the Abhishek, so the duplicate key is not allowed, anyhow there would be no error, but the value will get replaced by the new value.

No order there, similarly like a set. Heterogeneous values can be there. It is mutable, we can make changes. Slicing, indexing, etc are not there, due to no order.

Python Data Type: Bytes and BytesArray

l= [10, 20,30,40]

Till now it is a list. Now to convert it into the bytes we need to

Do-

b=bytes(l)

print(b)

Now It is used for the binary creation of the data. Bytes can only have values from 0 to 256. So basically if we add the value 256, 257 …

We will get the value error. Now in this as well indexing, slicing is there. But it is immutable, we cannot change its content. We will get an error. But if we want mutable bytes then it is known as Bytearray

l= [ 10, 20, 30, 40 ] b=bytearray(l) b[0]= 77 print(b[0])

None data type is nothing i.e no value is associated with it. To make the value available for the garbage collection-

a=None

None is also stored as object internally-

Print (type(a)) Escape Characters,  Comments, and Constants :

These are –

n  :   for the next line

t   :  for the tab space

r   : carriage return, means starting from the starting

b : backspace

f : form feed

‘ : for single quote

“ : for double quote

\ :   for backslash symbol

We need to put # in every line.

Constants :

The things of which we cannot change the values

So as such no constant concept is there in python, but if we want the value to be constantly put it in the upper case.

MAX_VALUE=10

For the convention purpose only.

End Notes

So we learned that Datatypes are an important concept because statistical methods and certain other things can only be used with a certain python data type. You have to analyze data differently and then categorize data otherwise it would result in a wrong analysis.

Related

You're reading A Comprehensive List Of The Different Python Data Types

## Redis Data Types: A Comprehensive Guide To Types And Commands

Definition of Redis Data Types

Redis data types is one of the most famous NoSQL databases, which finds its application in caching, storing, and managing user sessions, ad servicing, and recommendations. Redis is an open-source database server that stores data as key-value pairs in RAM memory. The keys manage, delete, and perform various operations on the values paired with them. The value can be any one of the data types supported by Redis. Some of the data types are strings, lists, hashes, sets, sorted sets, hyperloglogs, and bitmaps. Some of the commands are GET, LPUSH, HSET, and SISMEMBER.

Start Your Free Software Development Course

Key Highlights

Redis is an open-source database server that stores data in RAM as key-value pairs, which makes Redis remarkably fast.

Data types pair the keys with the values so you can perform various operations on them.

Some common Redis data types are strings, sets, sorted sets, hashes, lists, hyperloglogs, and bitmaps.

Each data type has its own command set for managing the access pattern regularly, providing transaction support, and performing a large number of operations in a constant time.

Redis Data Types

Data types and commands that are supported by Redis are given below.

a) Strings

Strings are a widely used Redis data type. It stores data in a sequence of bytes and is binary-safe.

Each string can store data up to 512 MB.

The data can be text, integers, floats, videos, images, and audio files.

Commands

String data type allows 3 types of commands.

SET command: It helps to create a new key-value pair in the database.

GET command: It helps to fetch the value of the specified key.

DEL command: It deletes the specified key and its value.

Example:

The command SET stores the value “project” in a key eduCBA.

The GET command retrieves and displays the value “project”.

The DEL command deletes the value in the key eduCBA and returns the number of values deleted.

b) Lists

Lists are strings sorted in an ordered sequence.

Lists allow simultaneous insertion of values both in the head and tail ends of the lists at a constant time.

The addition of values at a constant time is very helpful for faster writing operations.

Commands

LPUSH: It helps to push the value to the left end of the list.

RPUSH: It helps to push the value to the right end of the list.

LRANGE: It provides a range of items in the lists.

LPOP/RPOP: It helps to display and remove the value from both the right and left ends.

LINDEX: It helps to extract value from the specified position within the lists.

Example:

The addition of values to the list using LPUSH and RPUSH displays the number of values in the lists.

LRANGE provides the values in lists between 0 and 7.

c) Hashes

A Redis hash stores a large number of unordered objects or keys in minimal space.

It maps the unordered keys to the string values.

The value should always be a Redis string.

Other complex data structures are not allowed in Hash.

The Redis hash can store more than 4 billion key-value pairs.

Commands

HSET: It assigns a value to a key in the hash.

HGET: It fetches values associated with a key within the hash.

HGETALL: It displays the whole content of the hash.

HDEL: It deletes a key and its associated value from the hash.

Example:

The HSET command checks for the existence of the value.

It provides the output of the number of values entered in the hash.

Similarly, when the HDEL command is executed, it deletes the value and displays the number of values in the hash.

The HGETALL command displays all values in the hash key.

d) Sets

Sets are unordered collections of string values, and hence they prohibit duplication of data.

Since they are in an unordered sequence, you cannot add values to the right and left sides of the sets.

The values of the sets are very unique and non-repeatable.

Commands

SADD: It helps to insert a value into a set.

SISMEMBER: It helps to find the existence of value in a set.

SMEMBERS: It helps to fetch and display all values from a set.

SREM: It deletes the specified value from the set.

SRANDMEMBER: It helps to fetch a random set value from a set.

The SADD command adds the value “redis” to the set and returns the integer (1) since the number of values added is 1.

The SMEMBERS display all values in the set.

e) Sorted Sets

Sorted sets, otherwise known as Zests, are similar to the mix of Redis sets and Redis hash.

The key-value pairs in the sorted sets are made of distinctive string keys known as members and the value is known as scores.

The scores are nothing but a floating point value that sorts the elements or keys in the desired order.

If two scores are added to the same value, the last added score will exist in the sorted set by replacing the previously added one.

Command

ZADD: It helps to insert a key-value pair with a score into the sorted set.

ZRANGE: It displays values in the sorted order from low to high, based on the range of scores. The actual score values are displayed by using the WITHSCORES option.

ZREVRANGE: It displays the values of a sorted set arranged from high to low based on the range of scores.

ZRANGEBYSCORE: It displays values from the sorted set based on the predefined range of scores.

ZREM: It helps to delete values from a sorted set.

Example:

The command ZADD adds the value “redis” to the key along with the score 1.

The ZRANGE along with the WITHSCORES command displays the values and their scores sorted in ascending order.

f) HyperLogLogs

Hyperloglogs (HLLs) are probabilistic data structures.

It gives the count of the distinctive values in a collection.

Generally, the counting process requires memory equal to the number of values, whereas HLLs use fixed memory and reduce memory consumption.

The maximum memory size of HLLs is 12KB.

The Redis server stores the HLLs as Redis strings.

HLLs provide an approximate count of the values.

Commands

PFADD: It helps to insert one or several values into Hyperloglogs.

PFCOUNT: It helps to display the count of unique values from Hyperloglogs.

PFMERGE: It combines two different HyperLogLogs into a single Hyperloglog.

Example:

The PFADD command adds the value “redis” to the key eduCBA and displays the count as 1.

The PFMERGE combines the two values of the keys eduCBA and tutorial.

g) Bitmaps

Redis allows bit-level operations on strings known as bitmaps.

Bitwise operations are executed using commands in two ways: operation on single-bit and operations on groups of bits.

It saves more memory space when storing information.

Commands

SETBIT: It establishes the bits based on a 0 or 1 value.

GETBIT: It helps to fetch the bit value specified by a key.

BITOP: It helps to perform bitwise operations between strings.

BITPOS: It obtains the first bit with a specified value of 1 or 0 in a string.

BITCOUNT: It counts the number of bits set to 1 in a string.

Example:

The SETBIT considers the first argument as a bit number and the second argument as the value of the bit.

The GETBIT displays the value of bit 11.

Benefits of Redis Data Types and Commands

Since Redis stores data in RAM, it provides a super-fast website browsing experience and session storage.

Easy setup and faster access are the greatest benefits of Redis.

Redis has a unique hashing mechanism called Redis Hashing.

It exhibits a data replication process, hence any change in the master node will affect the slave node, and the data will be updated automatically.

It has a mass insertion mechanism that helps in loading millions of pieces of data into the cache in a short period.

Conclusion

Redis is extremely fast and is used in various applications. Each Redis data type finds its own applications to perform various tasks. Some applications are as follows: traffic balancing applications, social media posts, user data, ordered leader boards of player scores in an online competition, and unique user interactions or queries.

FAQs Q1. What are the data types supported in the Redis database?

The Redis database commonly supports seven types of data, such as strings, sets, sorted sets, hashes, lists, hyperloglogs, and bitmaps.

Q2. Why is Redis super-fast?

Redis is a type of NoSQL database server that stores data on disk, it stores data in RAM, which is much faster than on disk.

It supports well-organized lower-level data structures.

Redis also supports input/output multiplexing and a single-threaded execution loop for efficient execution.

Q3. What is the maximum number of keys that can be handled by Redis in a single instance?

In a single instance, Redis can handle up to 2^32 keys irrespective of data types. It was proved that per instance, Redis can handle up to 250 million keys.

Recommended Articles

This article explains everything about Redis Data Types and Commands. To know more about related topics, visit the following links:

## What Are The Different Types Of Classes In Java?

Types of classes in Java Concrete class

Any normal class which does not have any abstract method or a class that has an implementation of all the methods of its parent class or interface and its own methods is a concrete class.

Example

Live Demo

public class Concrete {    static int product(int a, int b) {       return a * b;    }    public static void main(String args[]) {       int p = product(2, 3);       System.out.println("Product: " + p);    } } Output Product: 6 Abstract class

A class declared with abstract keyword and have zero or more abstract methods are known as abstract class. The abstract classes are incomplete classes, therefore, to use we strictly need to extend the abstract classes to a concrete class.

Example

Live Demo

abstract class Animal {    public abstract void sound(); } public class Dog extends Animal {    public void sound() {       System.out.println("Woof");    }    public static void main(String args[]) {       Animal a = new Dog();       a.sound();    } } Output Woof Final class

A class declared with the final keyword is a final class and it cannot be extended by another class, for example, java.lang.System class.

Example

Live Demo

final class BaseClass {    void Display() {       System.out.print("This is Display() method of BaseClass.");    } } class DerivedClass extends BaseClass {    void Display() {       System.out.print("This is Display() method of DerivedClass.");    } } public class FinalClassDemo {    public static void main(String[] arg) {       DerivedClass d = new DerivedClass();       d.Display();    } }

In the above example, DerivedClass extends BaseClass(final), we can’t extend a final class, so compiler will throw an error. The above program doesn’t execute.

Output cannot inherit from final BaseClass Compile-time error - can't inherit final class POJO class

A class that contains only private variables and setter and getter methods to use those variables is called POJO (Plain Old Java Object) class. It is a fully encapsulated class.

Example

Live Demo

class POJO {   private int value=100;   public int getValue() {       return value;    }    public void setValue(int value) {       this.value = value;    } } public class Test {    public static void main(String args[]){       POJO p = new POJO();       System.out.println(p.getValue());    } } Output 100 Static class

Static classes are nested classes means a class declared within another class as a static member is called a static class.

Example

Live Demo

import java.util.Scanner; class staticclasses {    static int s;    static void met(int a, int b) {    System.out.println("static method to calculate sum");    s = a + b;    System.out.println(a + "+" + b); }    static class MyNestedClass {       static {          System.out.println("static block inside a static class");       }       public void disp() {          int c, d;          Scanner sc = new Scanner(System.in);          System.out.println("Enter two values");          c = sc.nextInt();          d = sc.nextInt();          met(c, d);          System.out.println("Sum of two numbers-" + s);       }    } } public class Test {    public static void main(String args[]) {       staticclasses.MyNestedClass mnc = new staticclasses.MyNestedClass();       mnc.disp();    } } Output static block inside a static class Enter two values 10 20 static method to calculate sum 10+20 Sum of two numbers-30 Inner Class

A class declared within another class or method is called an inner class.

Example

Live Demo

public class OuterClass {    public static void main(String[] args) {       System.out.println("Outer");    }    class InnerClass {       public void inner_print() {          System.out.println("Inner");       }    } } Output Outer

## Working And Different List Of Plugins In Ansible

Introduction to Ansible Plugins

Ansible plugins are separately available functions which are used to work with Ansible modules. These are the codes developed to provide additional support to Ansible modules while working on remote target hosts. Though the Ansible package comes with many plugins, we can also write our custom plugins. In Ansible, plugins are prepared in an architecture that adds more flexibility and expandability to the feature set. Most importantly, plugins are different from modules and run only locally on the Ansible controller node within the Ansible process. In addition, plugins provide additional options and extensions to the core functionality of Ansible, like output logging, inventory connection, data transformation.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Working of Ansible Plugins

Ansible plugins work locally on the Ansible controller node, which means some data is given to a plugin, and the plugin processes that data. Modules use this processed data to perform some tasks on remote target machines. This might look easy, but one can easily get puzzled while choosing or using plugins, as the syntax is not in YAML of JSON. Plugins follow a unique syntax which is different for different plugins.

To confirm your plugin is working or loading. You can use ansible-doc to check the plugin, run the command like below:

Ansible package is shipped with a range of plugins, including Action, Callback, Cache, Become, Connection, Inventory, Lookup, Shell, Vars, Filters, Test. Also, you can add your customized plugins by writing the incompatible version of Python, and code should have error reporting, return strings in Unicode, and line with Ansible documentation and configuration standards.  In the next section, we will learn about some of the default plugins types with examples.

List of Ansible Plugins

Below is a list of plugins types provided by Ansible packages, but you must note that this list if not exhaustive and can be extended in future releases or updated in the current release. In addition, these plugin types further have plugins that can use in our playbooks. For the latest list of plugin types, you can refer below the official Ansible community page.

To get a list of available plugin’s list of a plugin type, you can use the below command:

Also, for practical purposes, here we have an Ansible control server named ansible-controller and two remotes hosts named host-one and host-two. We will create playbooks, run Ansible commands on the ansible-controller node, and see the results on remote hosts. The way of use in these examples is completely to show you how to use these, but your real-life usage/requirements may be different from these.

1. Action

These plugins work on the front end and are executed in the local controller node before calling any module. These plugins are associated with some modules and are executed by default when such modules are used. Therefore, you cannot list action plugins.

2. Become

These plugins are enabled by default, and these are used to ensure that Ansible can use certain privileges on remote machines while running such commands, which need higher privileges. Plugin list includes sudo, su, doas, runas. These plugins are used along with become_methodkeyword in a playbook. For example, we have a playbook with content like below, here we are running this playbook with the root user, but as we mentioned becomes parameters in the playbook. We are trying to run the command as ec2-user. In the output, we will see that command ran as ec2-user.

Please note, this user must exist on the target machine, else the playbook will fail.

var: id_var[‘stdout_lines’]

ansible-playbook ansible_sudo.yaml

We get the output like below:

3. Lookup

These plugins are used to fetch data from an external source. This uses Jinja2. One of the important plugins is the file which is used to read the contents of a file. For example, we will take contents from a local file on the Ansible control machine and display its output using a plugin file which is a lookup plugin type. For this, we create a playbook, like below:

msg: These are the contents of /tmp/samplefile – {{lookup(‘file’, ‘/tmp/samplefile’)}}

Code:

ansible-playbook ansible_lookup_file.yaml

We get output like below:

4. Vars

These plugins provided additional data to Ansible plays which inventory, playbook, and parameters provided on the command line did not provide. These plugins are automatically enabled and used with keywords like host_vars and group_vars.

5. Cache

These plugins are used to store a cache of Ansible facts so that we do not have to gather those, again and again; this can be helpful in cost-saving where I/O is measured and incur costs.

6. Filters

These allow you to filter data within the controller node and provide it to playbooks and templates. This uses Jinja2. In this type, the variety of plugins is vast also; there are some mathematics-related plugins like abs, int, pow, root. To check some of these, we can make a playbook with content like below: –

msg: Fifth power of -2.5 is “{{ var_pow }}”

Code:

ansible-playbook filter_math.yaml

The output will be like below:

Conclusion

As we saw in this article, Ansible plugins can perform a vital part in Ansible playbooks, especially when we have needs like data transformation, filtering, etc. You must have good knowledge of using the plugins if you have multiple environments and your needs are to process data locally on the controller node. So learn it first and then use it.

Recommended Articles

This is a guide to Ansible Plugins. Here we discuss the Working and the list of plugins types provided by Ansible packages. You may also have a look at the following articles to learn more –

## Advantage Different Types Of Mutual Funds (Futures Guide)

Types of Mutual Funds – An interesting fact about mutual funds is that they are Split into numerous divisions based on the nature of the investment, closure of the scheme, and under-tax incentive schemes as well as the nature of payout. So, there is a typology within the categorizations which points to just how diverse mutual funds can be. The golden rule of mutual fund investing is that the higher the stakes, the bigger the reward. So, is a mutual fund in mutual interest? It depends on the match between the fund’s direction and the investor’s needs. Let’s explore just how many different types of mutual funds there are.

That said, mutual funds offer many benefits that trading on stocks does not. But along with these mutual funds benefits come the risks as well. Read on to learn more about the various kinds of top mutual funds today.

Start Your Free Investment Banking Course

Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & others

Mutual Funds -Varying Typologies

Based on the time of closure of the scheme, the mutual fund’s basics can also be divided into open and closed-ended schemes. Where there is no specific date when the scheme will be closed, it is open-ended. So, while open-ended funds are more liberal in their outlook, close-ended funds are fairly narrow-minded! While debt funds or schemes are also called income funds, diversified funds or schemes are called balanced funds.

Based on tax incentive schemes, mutual funds can split into tax saving and not tax saving funds. Another typology is possible based on periodicity/time of payouts, such as dividends. The categorization is as follows:

Dividend Paying Fund Schemes

Reinvestment Schemes

Schemes can also be in various permutations and combinations. For example, equity funding is open ended and can have a dividend-paying plan. What is important is that mutual funds work for the mutual benefit of investors and companies.

Look before your leap is a fit adage for the mutual fund markets. Before investment, one should be clear about the nature of the scheme and choose as per risk aversion and periodicity of dividends from the scheme.

Mutual Funds: Various Types Index Funds

They are those mutual funds that invest in a portfolio of securities representing the entire particular market or its piece. An example is the entire stock market or part of it, such as international stocks or small firms. Funds can be built to duplicate the performance of their relevant market. Index funds track the market’s indexes. These funds are affordably priced and easy to maintain. For instance, an NSE index fund will aim to provide the same return as the NSE index.

Actively Managed Funds

It is actively managed by professionals or portfolio managers who pick stocks that match investment strategies. Concerning the market index, such funds aim to outperform it. For example, rather than tracking the NSE index, active stock managers in India will try to outdo the index. Investors have to pay managers for their work, and it is up to the mutual fund managers to outsmart the index.

Lifecycle or Target Date Funds

It invests in a combination of bonds and stocks. These mutual funds originate from investments in several funds. The allocation of the fund to its investments changes over a while. With age, the investor turns older, and the ratio of money allocated to stocks versus bonds becomes conservative. It works well if you have a portfolio manager to monitor the funds.

Lifestyle funds involve a blend of stock and bond funds that do not change over time. Lifestyle funds can be moderate, aggressive, or conservative.

Tax-managed Funds

Balanced Funds

Basically, those funds invest in a combination of stocks and bonds. These funds typically have a conservative mix of close to 60% in stocks and the remaining pre cutting in bonds. Balanced funds are a combination of growth and income funds. They provide current income and more growth later. Such mutual funds have low to moderate stability. Further striking an even keel, they promise moderate mutual funds returns though the investor does experience some risk.

Income Funds

They are those mutual funds that invest in fixed-income securities, generating a regular income. Though this is a stable option, it is not without its risks. The income fund’s interest rates are sensitive to a certain degree.

Open or Close: The Many Options

A close-ended fund has outstanding fixed shares that operate for a fixed duration of around a decade. These funds have a set redemption period and are only available briefly. They appear on the stock exchange. All year long, flexible funds are available for subscription. These are open-end funds because investors have the flexibility to purchase or sell their investment at any point in time. These do not appear on the stock exchange, in contrast to close ended funds.

Opening a World of Possibilities: Different Open-Ended Funds

Debt/income plans use debentures, government securities, and other debt instruments to route a significant portion of the investable cash. With this kind of mutual fund, there is a low risk and low returns. Capital appreciation is low as against equity mutual funds.

Money market mutual fund schemes aim at capital preservation whereby gains will follow through as interest rates are higher on these funds as against bank deposits. These funds pose less risk and are highly liquid. These funds are ideal for investors who want short-term instruments while waiting for better options. Reasonable returns are the USP of these funds.

Equity or growth funds are popular mutual funds among retail investors. For long-term benefits, this is the best open-ended fund. It could be a high-risk investment for the short term, but it more than makes up for it in the long term.

Index schemes follow passive investment strategies and benchmark indices such as Sensex and Nifty. Another type of open-ended funds is sectoral funds invested in specific sectors such as IT, pharmaceuticals, or capital market segments such as small, medium, and large caps. The risks are high, but so are the returns.

Another type of open-ended scheme is tax saving which offers long-term opportunities and tax benefits. Called Equity Linked Savings schemes, they have a 3-year lock-in period.

Balanced funds are open-ended funds to enjoy growth and income at regular intervals and are perfect for investors who are cautious yet risk-taking.

Closing the Investment Gap Safely: Close-Ended Mutual Fund Schemes

Close-ended mutual funds have a stipulated maturity period, and investors can invest during the New Fund Offer period for a limited time. These are protective mutual funds that invest and guard capital simultaneously. A close-ended mutual fund is capital protection. The principal remains secure in this kind of fund while receiving acceptable returns. This mutual fund actively invests in high-quality fixed-income securities with limited exposure to equities.

Fixed Maturity Plans, or FMPs, are mutual fund schemes within a specific maturity period. Schemes include debt instruments that mature in line with a particular period and earn interest components of securities within a portfolio. Investors refer to the interest component of fixed-income securities as coupons. Passive functioning characterizes fixed maturity plans, which incur lower costs than actively managed plans.

Interval Mutual Funds: Best of Both Worlds

Operating within the combination of open and close-ended schemes, they allow investors to trade units at predetermined intervals.

Managing the Mutual Fund: Active Versus Passive Distinction

Actively managed funds mean there are active attempts by the portfolio manager to outperform the market or trade benchmarks. Passive management includes holdings where the securities to measure and replicate the mutual fund’s performance of benchmark indexes.

One of a Kind: Specialty Funds Funds of Funds: The Bigger Picture

These funds invest in other funds and are similar to balanced funds. They have higher MER as against stand-alone mutual funds.

The Philosophy of Investing: Many Approaches

Portfolio managers follow different investment philosophies and styles of investing to meet a fund’s investment objectives. Funds with different investment styles permit diversification beyond the type of investment and are a good means of reducing risk.

Top-Down Approach: This approach towards investing looks at the larger economic picture and invests in specific companies which look set to perform well in the long term.

Bottom-Up Approach: This focuses on choosing specific companies that perform well regardless of the state of the industry and/or economy.

A blend of the two generally follows portfolio managers overseeing a global portfolio.

Technical analysis is another style of investing that relies on past market data to detect the direction of investment prices.

Around the World: Mutual Funds by Region

Global or international funds are those where the investor invests anywhere in the world. The benefit of these funds is that they are a component of a well-balancing portfolio that carries country and political risks while reducing risk through diversification.

Sector funds are targeted at specific sectors of the economy, including health, finance, and biotechnology. It is a mutual fund scheme that is extremely risky and immensely profitable.

Regional funds focus on certain parts of the world, like a particular region or nation. These mutual fund stocks make investing easier in foreign countries, but you have to be ready for a high percentage of losses. Local factors tend to be very influential in deciding the fate of such mutual funds. From political leadership to economic status, the region’s dynamics affect the mutual fund and the money made from it.

Conclusion

Rob Chernow said that the best part about mutual funds is that they offer safety and diversification but do not necessarily offer diversification or safety.

Many analysts have discussed how mutual funds are subject to risks, and the offer document is an important consideration. Mutual funds have a risk-reward trade-off whereby the higher the risk, the greater the reward.

The only trick is minimizing the risk and maximizing the gains. But the catch is that reward is only possible where there is a risk. Mutual funds are a form of investment that is just as risky as futures trading the only difference is that you are entrusting the capital to a portfolio manager who is a skilled professional adept at getting the rewards without incurring the risks. Choosing the right mutual fund and how to invest in mutual funds can have immediate and long-term financial repercussions. Cash is a fact, but profit is an opinion. Mutual funds make that opinion a certainty.

Recommended Article

Here are some articles that will help you to get more detail about the Mutual Fund, so just go through the link

## Learn 4 Best Different Types Of C# Functions

Introduction to C# Functions

C# functions are the essential parts of the C# program that can consist of several elements, such as the function name that is used as the function’s reference, return types of the data operated in the functions, the logical body of the function, parameters that can be passed as arguments for the function, and the Access Specifier for defining the accessibility of the function inside the program. The different functions that can be integrated into a C# program are a combination of functions with or without parameters, which can or cannot have the return values, depending on the requirement provided.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

There are several components in functions –

We have a unique name called the Function name to make a function call.

We will use the Return Type to specify the return value data type.

The block of statements that contains the executable statements is called Body.

We can pass the functions during the function call as a list of Parameter arguments.

To specify the accessibility of function in the application, we can use the Access specifier.

Different C# Function

Without parameters(arguments) and return type.

With parameters(arguments) but without return type.

Using parameters(arguments) and with the return type.

Without parameters(arguments) and with the return value.

{ }

Return statements, parameters, and Access-specifier are optional in the above syntax.

Functional Aspects  Syntax(Function)

return values Declaration: int display ( int );

Function call: display ( value );

}

return values Declaration: void display ( int );

Call: display (value);

}

return values Declaration: void display ();

Call: display ();

}

return values Declaration: int display ( );

Call: display ( );

}

If a function’s return value is “void,” it cannot return any values to the calling function.

Note: If the return value of the function, such as “int, double, float, string, etc.” is other than void, then it can return values to the calling function.

1. Using Without Parameters and Without Return Type

We specified the function with no parameter and no return type, a function that does not return any values here, as void type as a return type value. In this program, any values should not be passed to the function call Display(), and also, there are no values that are returned from this function call to the main function.

Let’s see the example with a function build without a return type and parameter,

Example:

Code:

using System; namespace FunctionSamples { class Program_A { public void Display() { Console.WriteLine("Non Parameterized Function"); // No return statement } static void Main(string[] args) // Main Program { Program_A program = new Program_A (); // to create a new Object program.Display(); // Call the Function } } }

2. Using With Parameters (Arguments) and Without Return Type

In this program, a string is passed as a parameter to the function. This function’s return type is “void,” and no values can be returned. The value of the string is manipulated and displayed inside the function itself.

Example:

Code:

using System; namespace FunctionSample { class Program_B { public void Display(string value) { Console.WriteLine("Hello " + value); } static void Main(string[] args) { Program_B program = new Program_B(); // Creating Objec program.Display("Welcome to C# Functions"); // Calling Function } } }

Output:

3. Using With Parameters (Arguments) and with Return Type

In this program, a string is passed as a parameter to the function. The return type of this function is “string,” and the return value of the string can be returned from the function. The value of the string is manipulated and displayed inside the function itself.

Example

Code:

using System; namespace FunctionsSample { class Program_C { public string Show(string message) { Console.WriteLine("Inside the Show Function Call"); return message; } static void Main(string[] args) { Program_C program = new Program_C(); string message = program.Show("C# Functions"); Console.WriteLine("Hello "+message); } } }

4. Using Without Parameters (Arguments) and with Return Value

In this program, arguments or parameters will not be passed to the function “calculate” but to the main function; the values are returned from this calculate () function call. The variables a and b values are calculated in the function called “calculate,” and in the main function, the sum of these values is returned as a result.

Example:

Code:

using System; namespace FunctionsSample { class Program_D { public void calculate() { int a = 50, b = 80, sum; sum = a + b; Console.WriteLine("Calculating the given to values: " +sum); } static void Main(string[] args) { Program_D addition =new Program_D(); addition.calculate(); } } }

Output:

C# Passing Parameters to Methods

When creating a method with arguments/parameters in c#, we must pass arguments/parameters to that specified method when calling our application’s function. We have several ways to pass parameters to the method; let’s see the parameters/arguments.

Parameters Description

Value Parameters Value parameters are called the “input parameters.” Instead of the original parameters, the input parameters will pass a copy of the actual value; due to that, there will not be any cause or changes made to the parameter during the called method, and it will not affect on original values while the control passes to the caller function.

Reference Parameters Reference parameters are called the “input/output parameters.” The reference parameter will pass the reference memory of the original parameters. Thus, the changes/alteration made to the parameters in called method, while the control returns to the caller function, affects the actual values.

Output Parameters

It is an “output parameter” like the reference type parameters. The only difference is there is no need to initialize it before passing the data.

Conclusion – C# Functions

In this article, we well-read the usage of the functions/ methods available in C# and learned the different C# functions. I hope this article has helped you understand the several functional aspects of C#.

Recommended Articles

This has been a guide to C# Functions. Here we discussed the basic concepts and different types of C# functions with their syntax for better understanding. You can also go through our other suggested articles to learn more –

Update the detailed information about A Comprehensive List Of The Different Python Data Types on the Katfastfood.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!