6.00 introduction to computer science and programming lec2

Source: Internet
Author: User

Starting from this lesson, we will introduce Python-related things in 6.00. The first step is to configure the environment, that is, install Python (2. x series) and the corresponding idle. In ubuntu, Python comes with python. For example, it is easier to install Python 12.10. idle in Ubuntu 2.7. Use sudo apt-Get install idle to install it.

How to start learning an object-oriented language? Here is a question: What Is Object-Oriented?Program? The answer to 6.00 is as follows:

Type> Expression> Control> input/output

Type is a decisive element that gives meaning to the cold ice 10, for example, 0110 1100 0110 1111 0111 0110 0111 0101 interpreted as characters according to ASCII rules, it can produce the beautiful word "love. What is a type? I think the type is the value range of the index data and the operations that can be performed on the data. For example, a 32-bit integer defines 32 bits to represent itself, and also specifies the corresponding operation in syntax.

In object-oriented programming, a class is the most basic concept. A real object-oriented programming language should classify all data into a class.

With the class, the next step is to make these classes work together, so the next concept comes out naturally: expressions.

An expression is a combination of operators and operation numbers.

Input and Output: the input and output are generally not in the core of the language and are usually in the form of libraries, for example, the famous printf in C. Why do I learn the input and output databases when learning new languages? Naturally, we hope to get a "live" program immediately, even if we print a "hello World", it will make new users feel angry, I still remember my excitement when I used C to play Hello world in DOS, as if I had magic :)

The following are Python-related parts:

Type (x): Data Type of output X, such as int, STR, nonetype

Print X or print (x): output the value of X.

Raw_input ('msg '): Get user input

INT (x): Convert X to int type data

Control Structure:

If expr:

Statement

Elif expr:

Statement

Else expr:

Statement

Whle expr:

Statement

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.