Basic knowledge of Python-Introduction to quick transformation

Source: Internet
Author: User

Basic knowledge of Python-Introduction to quick transformation

Note: Python is a magic language. I will share with you the Python learning process, especially the comparison between C and C ++.

In addition, it should be noted that Python is not from the Python word.

1. Why Python?
Let's take a look at the comments on other languages:
Writing C Programs is like a group of people taking a razor and dancing fast in a newly waxing dance stage.
C ++ is difficult to learn and use.
Java is like C ++ in many aspects.
Python is a programming language that lets you work quickly and integrate systems more than tively.

It should be noted that Python makes your work faster, rather than running your program faster. If the running speed is particularly emphasized, select C and C ++.

2. Overview of Python
Python is an interpreted, object-oriented, advanced programming language with dynamic semantics.

3 install Python, omitted.
Https://www.python.org

4IDE
JetBrains PyCharm
PyCharm is a Python IDE with a complete set of tools to help users improve their efficiency when developing using the Python language, such as debugging, syntax highlighting, Project management, code jump, smart prompts, Automatic completion, unit testing, and version control. In addition, the IDE provides some advanced functions to support professional Web development under the Django framework.

Https://www.jetbrains.com/pycharm/download/

5. Numbers and expressions

>>>1.0 / 2.00.5

If you want to execute a common Division:

from _future_ import division

Power Operation:
Here we can write two titles, indicating power calculation:

>>>2***38

L is added after a long integer.

6 variables
Here, the benefits of C and C ++ programmers come, and variables no longer need to be displayed of the specified type. The naming rules for variables are the same and cannot start with a number.

7. user input
C ++ uses cin, while Python uses input and print output.

8 functions
I just mentioned that power operations also have functions. In fact, the std namespace in C ++ also has this function:

>>>2***38>>>pow(2,3)8

It should be noted that there are no longer braces in Python.

Describes a round function:
Round the floating point number to the nearest integer:

>>>round(1.0/2.0)1.0

9 Module
It can be understood as a library in C ++.

import math>>>math.floor(32.9)32

Cmath can be used for plural operations.

10 annotations
It is very different from other languages and is no longer used/or /**/
Instead, use #

Finally, let's look at a piece of code written in Python:

# Python 3: Fibonacci series up to n>>> def fib(n):>>>     a, b = 0, 1>>>     while a < n:>>>         print(a, end=' ')>>>         a, b = b, a+b>>>     print()>>> fib(1000)

The next article will introduce the string ~

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.