Python (ii) run the first Python program

Source: Internet
Author: User

1. Output

#OutputPrint()Print("Hello World")Print("Hello","Willow","Output")Print("+ + =", 100+200)Print(100+200)

2. Enter

# inputname = input () nameprint= input ("pleaseEnter your name: " )print("Hello,", name)

3. Code block

Code block with: and four spaces in the indentation in the embodiment

# print absolute value of a inta =if a>=0:    print(a)else :     Print (-a)

4. Save and run

In the Python command-line interactive environment, you can only enter one line of code and execute one line. Can't save and run again, and if you want to run again, you need to enter the same code again, what do you do?

We can choose a text editor, for example: Sublime text, write the code in, save the file as. py, and then go to the cmd command line

1) Enter the folder under which the. py file is saved

2) more + *.py can see all the contents of the file

3) Python + *.py execute this file

Ps: Under Windows. py file is no way like the. exe file, double-click the run, must pass the above steps. Python's idle also has no effect.

Python (ii) run the first Python program

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.