Connect with us

Hi, what are you looking for?

Programming

Python For Data Science (2)

Python For Data Science (2)
Python For Data Science (2)

 

In this tutorial, we going to learn data types, type conversations, 4 operations. Before start, if you don’t read Python for data science (1) you should read this tutorial. Let’s start learning Python.

What Is Data Types?

used to inform the computer how to use the data. In languages ​​such as C # and Java, you have to write these structures while specifying the data. In Python, the data type is automatically determined according to the value.

  • List
  • Tuple
  • Dictionary
  • String -> Text
  • Int -> integer
  • Bool -> True or False (Logic)
  • Float -> Decimal Number

I gave some data types above, there are a few more data types besides these, we learned other simple data types. It is enough to know this concept now, we need to learn 4 operations and type conversion.

4 Operations In Python

In this section, we will look at concepts such as addition, multiplication, division, subtraction, getting mod, exponentiation.

1 – Addition

Just like in mathematics, + is used for addition. only here you can addition strings as well as integer numbers.

Above, we gather 2 integer variables after that, we write this sum on the console. Now we’ll look at adding decimals.

 

above, we gather 2 decimal numbers, so the console will display a decimal result instead of an integer result. Now, we going to learn to gather 2 strings.

 

above, we collect the two strings and as a result, “XY” is output without spaces.

2 – Multiplication

The multiplication is indicated by * instead of the x symbol. It’s almost the same as multiplication in math, except programming can also a string can also be multiplied by integers.

Above, we multiplied two whole numbers. In the same way, we can multiply 2 decimal numbers.

 

Now, let’s do the string multiplication, which is not in mathematics but is also in programming.

 

here the string statement is printed twice, if I set the “a variable” as 3, it is printed 3 times. In other words, when the strings are multiplied, it occurs as much as the value it is multiplied.

Division And Subtraction

We will look at division and subtraction it is exactly the same as mathematics, everything will be understood in the example below.

Getting Mode And Exponentiation

We will first look at the “exponentiation” that we are familiar with from mathematics, then we look at the “getting mode” slightly unfamiliar modification operator.

 

In the above process, 120 by 21 is divided and the remainder is written on the screen.

Note: You can use // to divide without a remainder.

Type Conversation (String, Int, Bool, Float)

Now we’ll look at how to switch data types, a of important information, not all data types are transformed into each other. Let’s start this part.

above, we have converted several data types to each other, but more importantly, different types of data can be received with this type of conversion. Let’s ask the user for an integer data type.

If you want to print the data type on the screen, you can use the type () function.

 

CONGRATULATIONS! YOU PASSED PYTHON FOR DATA SCIENCE (2)

Click to comment

Leave a Reply

Your email address will not be published.

You May Also Like

Cyber Security

TCP/IP is a set of rules that allow computers to communicate with each other on a network such as the Internet. Currently, we do...

Cyber Security

Search engines are filled with more and more data and information every day. Search engines are your best friend when you want to gather...

News

According to a study from Dartmouth College, Dartmouth’s Tuck School of Business, and Indiana University, artificial intelligence systems can be trained to produce human-like...

Cyber Security

There is a systematic order (layer ordering) in networks for data transfer to occur. These layers are responsible for transmitting the data to the...