Python Learning record One

Source: Internet
Author: User

First, common functions

1.input function

The value received by the input () function is all string type, and if you want to compare it with the int type, you must use INT () to convert the string to int type to compare

2. Print () function

# Print (1/2)
# print (1//2) #地板除, is automatic rounding, will not be rounded, directly erase the decimal part

#在python2里面, so the arithmetic print (1/2), the result is not correct, because in the python2 inside
#int和int类型运算会自动取整, there's no problem in Python3.

#if判断时候, both true and false, that is, true and false.
#记住一句话, not 0 is true, non-empty is true

difference between IS and = =

Objects in Python contain three elements: ID "memory Address", type, value
Where the ID is used to uniquely identify an object, type identifies the object, and value is the object's
is determines whether a object is a B object and is judged by its ID.
= = Determines whether the value of a object is equal to the value of the B object, as determined by value.
The following code may help you to understand.
#is Determine the memory address is the same
# name1 = ' Zhangsan '
# Print (ID (name1)) #查看内存地址
# name2 = ' Zhangsan '
# Print (ID (name1)) #查看内存地址
# print (name1 is name2)

Three, string

1. String format:

  Example: A = ' username '

2. String specificity

A. strings can be searched by subscript

Perform a print result of

B. String cannot be changed

"Include conversion string type" error when executing changes

C. Convert to string with STR ()

Execution Result:

 

Python Learning record One

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.