Get the App
SLTechnology News&Howtos  ›  Development  › 

Sample Analysis of variables and data types in python

Shulou Source: shulou.com Published: 2022-06-01 07:57:17 09月24日 Update

Editor to share with you the sample analysis of variables and data types in python, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Variables and data types

Assignment does not need to specify a type, how to define variables

# define rule variable name = data adept 10 # python does not declare data types, so values must be assigned when defining variables

Av10 # python does not declare data types, so you must assign a value to a=20print (a) # use a to define the variable before it can be used, the variable can be changed # the value can be changed during program execution

The value can be changed directly without definition.

Enter the python terminal directly from pycharm

Realize numerical access through variables

Output element type

Print (type (a))

# Advanced type b = () # meta-ancestor type print (type (b)) c = [] # # list type print (type (c)) d = {} # # dictionary type print (type (d))

Naming rules for variables in Python

Name='liudehua' # cannot start with a number print (Name) _ age=89print (_ age)

Name='qianiqan' # case-sensitive print (name) # color changes can be considered that the keyword cannot be the variable name True=10print (True)

Naming convention

The above is all the content of the article "sample Analysis of variables and data types in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Variables types data articles examples analysis content rules advanced not so elements keywords keywords size most dictionaries beginnings numeric values numbers more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS vpn MySQL Microsoft