Python Learning chapter I (Python Basic Programming second edition)

Source: Internet
Author: User
Tags pow

Chapter One: Basic knowledge

1. Double slash: The operator that implements the divide

>>>1//2

0

Even if it is a floating-point number, the slash will perform the divide

>>>1.0//2.0

0.0

2. Power (exponentiation) operator: Double star

>>>2**3

8

Tip: You can use the function POW instead of the operator, pow (2,3)

3.16 Binary and octal

Hex: Front plus 0x, first is number 0

>>>0xaf

175

Octal: Add 0o to Python in version 3.0, the first number is 0, the second is the letter O

>>>0o10

8

4. Get user input

With the python3.5.0 version, you need to convert the string operation if you enter a number

>>>x=input ("x:")

X:34

Here the 34 default is the string, if the need is a number, then the conversion operation

>>>x=int (Input ("x:"))

X:34

The value of x here is a number, which can be manipulated

5. Functions

The round function rounds the floating-point number to the nearest integer value

>>>round (1.0/2.0)

Python Learning chapter I (Python Basic Programming second edition)

Related Article

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.