Python Basic Tutorial Notes--1th Chapter

Source: Internet
Author: User

1.8 functions

Pow (x, y) x^y

ABS (x) The absolute value of the take number

Round (x) rounds a floating-point number to the nearest integer

Floor (x) to take down the entire function, but first import the math module

1.9 Modules

Importing modules with import to extend Python's functionality

(1) Import module then use: module. function

(2) The From module import function then use: function

(3) Use a variable to assign a value, and then use the function, such as: Foo=math.floor () foo (12.9)

Math module and Cmath module

(1) math.sqrt can only handle floating-point numbers, cannot handle complex numbers, i.e. math.sqrt (-1) is meaningless

(2) cmath.sqrt can handle complex numbers, i.e. cmath.sqrt ( -1) =1j

The Python language itself supports support for complex numbers

1.10 Saving and executing a program

To run the program:

In the idle edit box, write the code and save, and run to execute

Or, under the cmd command line, assume that there is a file hello.py cmd under Python hello.py

Let the Python script normal program do the same

Linux under: #! /usr/bin/env python

Under Windows: Click on the file directly, but will jump off immediately.

Comments

# HHDAHFHH

1.11 String

Single-quote strings and transfer quotes

>>> "Hello" >>> ' hello ' are all correct

If you encounter "or" in the middle, you can use a backslash \

Python Basic Tutorial Notes--1th Chapter

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.