[Basic learning python] Start real programming

Source: Internet
Author: User

[Basic learning python] Start real programming
Through the study of the four arithmetic operations, we have initially come into contact with the content in Python. It may be a bit confusing if the reader is a zero-base learner. Do I have to write a few commands in IDE and then see the results? Isn't that a program that can run automatically?

Indeed. Currently, programming is not supported, but some commands (or commands) can be used for simple work. The IDE interface where the official website is located is also used to input commands.

The column is a bit secure. Next we will learn how to compile a real program. The tool is still the IDLE, but please remember that for a real program, it doesn't matter what tool is used, as long as you can write instructions, such as using notepad.

I went to pour a cup of tea and read the following section carefully. The content of the program concept comes from Wikipedia:

First read a piece of English: computer program and source code. It doesn't matter if you don't understand it. You can jump over and look at the next one.A computer program, or just a program, is a sequence of instructions, written to perform a specified task with a computer. [1] A computer requires programs to function, typically executing the program's instructions in a central processor. [2] The program has an executable form that the computer can use directly to execute the instructions. the same program in its human-readable source code form, from which executable programs are derived (e.g ., compiled), enables a programmer to study and develop its algorithms. A collection of computer programs and related data is referred to as the software.

Computer source code is typically written by computer programmers. [3] Source code is written in a programming language that usually follows one of two main paradigms: imperative or declarative programming. source code may be converted into an executable file (sometimes called an executable program or a binary) by a compiler and later executed by a central processing unit. alternatively, computer programs may be executed with the aid of an interpreter, or may be embedded directly into hardware.

Computer programs may be ranked along functional lines: system software and application software. Two or more computer programs may run simultaneously on one computer from the perspective of the user, this process being known as multitasking.

Computer Program

A Computer Program refers to a group of instructions that indicate each step of a Computer or other device with information processing capabilities. It is usually written in a programming language, it runs on a certain target architecture. For example, a program is like a braised pork Recipe (Program) written in Chinese (programming language), used to guide people who understand Chinese and cooking techniques (Architecture) make this dish. Generally, computer programs are compiled and linked to become a format that is hard to see and can be interpreted by computers and then run. Programs that can run without compilation are usually called scripts ).

Biluochun is my favorite. Someone will give me a gift. Don't forget it. Do I expect an official reception? Hahaha

Start to talk about programs. In short, a program is a set of commands. However, some programs need to be compiled, and some do not. A program written in python is not required, so it is also called a script program. Special reminder column spaces. Do not think that compilation is good or compilation is not good. Do not think that compilation is "high-end" or that non-compilation is "low-end ". There may be some programmers who have been programming for many years or others who may have such an idea, which is unfounded.

No argument. It's good to use it.


IDLE programming environment


Operation: File-> New window

In this way, a new operation interface is displayed, in which the prompt used to input commands is not displayed: >>>. This interface is a bit like notepad. By the way, it is essentially a notepad. It can only input text and cannot directly paste images in it.


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Release + release/LKwL3ntcSx6ta + o6zL + release/XU2sSzuPa + release/nS1KOsy/nS1L + release + vKwL3nSGVsbG + release + 0 + sLro6y + release/release + upload "brush: java; "> print" Hello, World"
For example, Style

As mentioned above, a program is a set of commands. Now, there is a command in this program. A command can also be a set.

Note: There is a RUN on the menu. Click this menu and select Run Moudle from the drop-down list.

In the dialog box that appears, you need to save the file. This is simple. Save it to a location. The viewer must remember this location and get a file name. The file name is. py is the extension.

After you complete the configurations, click "OK" and you will find that the Hello and World characters are automatically displayed in another interface with >>>.

Succeeded? Don't be excited when you succeed, because there is no time to celebrate.

In this case, we still implement the automatic execution of the program in the IDLE environment. What if we leave this environment?

Close IDLE and Open shell (if you are using Apple's ms xos operating system or a linux release operating system, for example, I am using ubuntu ), or open cmd (windows OS users, especially those who use windows,It is not your fault to use windows. If it is wrong, you will only use the mouse to point it, instead of using or using commands, or even linux commands, he also dreamed of becoming a good programmer.), Run the command to enter the directory where you saved the file.

It is the address where I saved the file. I named the file 105.pyand saved it in a folder.

In the shell, enter python 105.py.

The meaning of the above sentence is to tell the computer to run a program written in python. The program file name is 105.py.

I am the master of my computer. So it gave me the command. For example:

Still silent? You can cheer. The German team wins the Brazilian team by and is listed as an official player. Fans of both the German team and the Brazilian team can cheer, because you have made a great second step on the programmer's road. By the way, the final World Cup champion should be: Chinese team. (Is there anything else ?)


Solve a question


Please calculate: 19 + 2*4-8/2

The Code is as follows:

# Coding: UTF-8 "Please calculate: 19 + 2*4-8/2" a = 19 + 2*4-8/2 print

Reminder for beginners,Do not copy this code. Instead, you need to enter it with one word. Then save (my saved file name is: 105-1.py ).

In shell or cmd, run python (file name. py)

The execution result is as follows:

Python.

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.