Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commonly used data types in Python

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "what are the commonly used data types in Python". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what data types are commonly used in Python.

Variables do not need to be declared

The variable of Python does not need to be declared, you can type it directly:

> a = 10

Then you have a variable an in your memory, which has a value of 10 and a type of integer. You don't need to make any special declaration before that, and the data type is automatically determined by Python.

> > print (a)

Print (type (a))

Then the output will be as follows:

ten

Here, we learned about a built-in function, type (), to query the type of variable.

Reclaim variable name

If you want a to store different data, you can assign values directly without deleting the original variables.

> a = 1.3

> print (a ~ ())

The output will be as follows

1.3

We see another use of print, where print is followed by multiple outputs, separated by commas.

Basic data type

Av10 # int integers

Av1.3 # float floating point number

A=True # True value (True/False)

A string of characters Hellograms'#. Strings can also be in double quotes.

At this point, I believe you have a deeper understanding of "what data types are commonly used in Python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report