Python Day 1-getting started with Python (1) data definition, python Day 1

Source: Internet
Author: User

Python Day 1-getting started with Python (1) data definition, python Day 1

Data Type:

What is data?

In computer science, data refers to the general term of all the symbols that can be input to a computer and processed by a computer program. It is used for input to an electronic computer for processing, it is a general term for numbers, letters, symbols, and analog numbers. Nowadays, computers store and process a wide range of objects, and the data of these objects becomes more and more complex.

For example:

In the game, you will have your own characters, equipment, grade, money, etc. These are data, but in Python, these data have their own types. How do they represent them?

1 For example with cs 2 Name: Chares_Lee --------------------> string 3 money: 7500 ----------------------> Number 4 equipment: AK-47, flashing bullet, bulletproof vests ---------> List 5 Kill Number: 15 ------------------------> Number 6 and so on. There are many other types of data. To process different types of data, you need to define different data types.

1. Basic data types include:

Number (integer, long integer, floating point, Boolean, plural)

1. Integer: According to the literal meaning, There is no number of decimal points.

2. Long Integer: A long integer

3. Floating Point: numbers with decimal points

4. boolean: True and False (1 and 0)

5. plural: the plural is composed of a real number and a virtual number. Generally, x + yj is used. x is the real number of the plural, and y is the virtual Number of the plural. Here, x and y are both real numbers.

Note: The letter j in the description part is case-insensitive.

 

Binary string

How does one define a string as a string in python?

Use "", '', ''', or """""". The portion in the middle is called a string.

PS: Even if a number is written in it, its data type is also a string

For example, name = 'chares _ Lee'

In '', It is a string.

1. Use three quotation marks (''' or """) 2. You can use three quotation marks to indicate a multi-line string. You can use single quotation marks and double quotation marks freely in the three quotation marks, for example, 3''' This is a multi-line string. this is the first line.4 This is the second line.5 "What is your name? "I asked.6 He said" Chares Lee. "7 '''

Note that the string cannot be changed.

Common string operations include:

Remove blank, separator, length, index, slice,

 

 

Iii. List

[] Separated by commas (,), stores various data types based on indexes. Each location represents an element.

Definition list

List1 = ['chares _ Lee ', 20, 'beijing']

Or

List1 = list ('abc ')

Or

List1 = list (['chares _ Lee ', 20, 'beijing'])

Common List operations include:

Add, insert, delete, query, slice, index, length, etc.

 

.

.

.

.

.

 

Variable

What is a variable?

The literal meaning is interpreted as the amount of change. The specific explanation is: save state (the essence of the program's operation is a series of state changes, the purpose of the variable is to save the state, the variable is worth changing is the different results of the hook program running)

For example, each person in the league of legends has their own blood volume. When the blood volume is greater than zero, life = active is alive. When the blood volume is equal to zero, change the variable to life = inactive, indicates death.

Variable Naming Standard

The first character of the variable must be an uppercase or lowercase letter or an underscore ('_').

The other part of the variable name can be uppercase or lowercase letters, underscores ('_'), or numbers (0-9. Variable names are case-sensitive. For example, myname and myName are not valid for an identifier. For example, I, _ my_name name_23, and abl2_c3, invalid variables include 2 things this is spaced and my-name.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.