Python base, string, and if condition statements

Source: Internet
Author: User

One: Python basics

1. File suffix name:. py

2, Python2 to read Chinese in the file header write:-*-coding:utf8-*-

3. Input uses n as a variable, substituting a value for a change

n = input (' Enter user name: ') waits for the user to enter a value, the value entered by the user will be assigned to the N,n to refer to what the user entered.

4, the variable can only be composed of letters, numbers, underscores.

Cannot start with a number.

You can't start with a python keyword:

5, n= "Pepper" assignment value

n== "Pepper" comparison

Two: string

String: The part of quotation marks is called a string.

Character: The string content that is quoted by quotation marks is called a character.

  string addition :

" Alex "  "sb"= n1 + n2 print N3: ALEXSB

 String multiplication:

" Alex "  = N1 *10 print N2: Alexalexlaex ..... (10 Alex)

Digital:

For example:

N1 = 9= 2                            = n1 + n2   = n1- n2    = N1 *= n1/= n1% n2< c10/> Division takes remainder  = N1 * * N2
N3 = n1//N2 Division distributor

Three: F conditional statements

ifINP = ="Senior Member"    Print("Beauty")elifINP = ="Platinum Member"    Print("Morgan Stanley")elifINP = ="Platinum Members"    Print("A little star .")Else:Print("Chengguan")Print("start the service.")

Four: While Dead loop

   

count=0 while Count < :    print(    count)= Count +1Print ("1, 2, 3,,")

  

Python base, string, and if condition statements

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.