Python Notes---DAY1: basic operations, if statements

Source: Internet
Author: User

1. Output string:

Print (" string ")

2. Open the document file with python :

CMD Command indicator

CD C + + where cd is Chang directory Change directory, with tab key to quickly find the target file

Dir View current directory file list

3, thecmd operation:

D: The second time you change the directory without adding \

CD: return to the previous level directory

Cd.. \.. go back to the two-level directory

Execute Command Destination file directory open a file with the program you are using

Exit exits

-V View version

4. Description Data:

Student_numbers=1 using underscores instead of spaces

Studentnumbers=1 Hump Body

Pie=3.14 constants All in uppercase

5. Delete variables:

Del variable

6. View variable types:

Print (Type ( variable ))

7. Comments:

# Command line comment

"' command

command ' multiline comment '

8. Interactive applet:

death_age=100

Name=input ("Your Name:") input result defaults to string

Age=input ("Your Age:")

Print ("Can Live", death_age-int (age), "years!")

string to Integer:int ( data )

Integer to string:str ( data )

9, Guess the Age program:

age_of_god=100

Guess_age=int (Input ("Guess_age:"))

If age_of_god==guess_age: use double equals when judging

Print ("You are right!") Note tab indent

Else

Print ("You are wrong!")

10. Multi-Branch if statement:

Score=int (Input ("score:"))

If score>90:

Print ("A")

Elif Score>80:elif=else If

Print ("B")

Elif score>70:

Print ("C")

Else

Print (" dumb ")

Python Notes---DAY1: basic operations, if statements

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.