Python BASICS (II): python Basics

Source: Internet
Author: User

Python BASICS (II): python Basics

1. Install python's ied pycharm (Professional Edition is not Chinese)

2. Operators

+,-, *,/, **, //, %

Determines whether something contains

In

Not in

 

Result is a value

Arithmetic Operations

A = 10*10

Value assignment

A = a +! A + = 1

   

The result is a Boolean value.

Comparison

A = 1> 5

Logical operation

A = 1> 6 or 1 = 1

A = 1> 6 and 1 = 1

Member operation

A = "small" in "Small lingering"

A = "small" not in "Small lingering"

 

3. Basic Data Types

Number int

-Int
Converts a string to a number.
    

       a="123"    print(type(a),a)    b=int(a)    print(type(b),b)    num="0011"    v=int(num,base=2)    print(v)            

  

-Bit_lenght
The binary value of the current number, represented by at least n digits.
R = age. lenght ()

   

    age=2    r=age.lenght()    print(r)  

  

String str

 


# Uppercase letters

test="alex"v=test.capitalize() print(v)

 

# All the small write casefold and many unknown ones can be changed
Lower can only be well-known

v1=test.casefold()print(v1)v2=test.lower()print(v2)

  

# Set the width and center the content
Total length of 20, * blank position filling, one character, optional

v3=test.center(20,"*")

  

# The number of times a subsequence appears in a string. The two parameters are the start position and end position, which are optional.

v4=test.count('l',1,4)

 

# Determine the end and start of a parameter. The two parameters start and end. They are optional and the output result is True or False.

v5=test.endswith('ex',1,4)v6=test.startswith('a')

# Search from the beginning, find the first one, and obtain its location

v7=test.find('ex')

  

# Format and replace the placeholder of a string with the specified value.

test='I am {name},age {a}'print(test)v=test.format(name='Christian',a=26)print(v)

 

test1='I am {0},age {1}'print(test1)v1=test1.format('C',19)print(v1)

  


# If the string contains only letters and numbers, the result is true False.

v=test.isalpha()

  


 

List

Yuanzu tuple

Dictionary dict

Boolean bool

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.