day01 python basis 1

    name=' aleX  '
    print(name)
    print(name.strip())
    print(name.startswith('al'),name)
    print(name.startswith(' al'),name)
    print(name.endswith('x'),name)
    print(name.replace('l','p'))
    print(name.split('l'))
    print(name.upper())
    print(name.lower())
    print(name[1])
    print(name[0:3])
    print(name[-2:])
    print(name.split('l'))
    print(name.rstrip(name[-1:]))

Today's content:

python basis:

A programming language

What is a programming language?
Expression can be recognized by a computer programming language mentioned above, i.e., the language of communication media, and programming language programmers
and computer communication medium. In the programming world, a computer is more like a slave to the purpose of human programmed to command the slaves to work.

What is programming?
Programming that is based on the needs of programmers to write down their thoughts flow in accordance with the syntax of a programming language style, the result of output
is a file that contains a bunch of characters.

Stressed:
the program is no different with the ordinary file before is not running, the characters only at run time, the paper wrote only specific grammatical meaning
.

Second computer component of the
CPU
memory,
external memory
input device
output device

Installation and use of the three python
1. Install python interpreter
2. Install pycharm editor
3. Write python code, and outputs the print hello world!


Four Variable
amount may change.
Variable value: true to store a memory address in memory.
Variable name: variable values for binding relationship.
= Number assignment: to bind the value of the variable to the variable name.

Five constants
can not change the amount.
Named to all uppercase.
Not can not modify them, but everyone who ordained all uppercase variables are called constants, can not be modified.

Six user to interact with the program
input:
the INPUT ()

Output:
Print ()

Seven formatted output
user Dear, Hello! Your month deducted 99 yuan bill, left 0.

# By some placeholder character for a location in the replacement string.

Placeholder:
% S: can replace any type of
% d: can be replaced by a digital type

Example:
Dear customer, hello! Your phone bill this month deducted yuan% s,% d remaining yuan.

Eight basic data types
1. Digital Type:
Integer: int

Float: float

2. String type
role: name, sex, nationality, address and other descriptive information

Definition: single quotation marks \ double quotes \ three marks, a string of characters
name = 'tank'

The priority control operations:
1, according to the index value (Forward + Reverse take take): can only take
2, sections (care regardless of the end, step)
3, the length len
. 4, the members in operation in and Not
. 5, shift In addition to the blank Strip
. 6, segmentation Split
. 7, loop

Need to know:
. 1, Strip, the lstrip, The rstrip
2, Lower, Upper
. 3, startsWith, endsWith
. 4, the format of the three kinds of games are played
. 5, Split, rsplit
. 6, the Join
. 7, Replace
. 8, isdigit



Guess you like

Origin www.cnblogs.com/songsky/p/11080159.html