Operation and Flow Control

1. Built-in functions

len is determined string length or number of elements

in determining whether the element belongs to the set, lists, dictionaries

not in

 

2. The identity of the operator

id is determined whether the two variables are equal

== determines whether the value of the variable is equal to two

 

3.if Process Control

if conditions:

command

elif condition:

command

else:

command

 

4. The variable type immutable type

Variable: In the case of the same id may change value (lists, dictionaries, collections)

Immutable: value once changed, id also changed (explain opened a new memory space)

 

5.while Process Control

while conditions:

command

Remove the elements in the list:

l1 = ['1','2','a','b','f','g']

a = 0

while a < len(l1):

    print(l1[a])

    a += 1

while and can be used in conjunction else, will execute the else statement after the while loop execution is completed

 

6.random random module

import random

 

computer = [ 'rock', 'scissors', 'cloth']

res2 = random.choice(computer)

 

 Since part of the statement has been studied in the shell and substantially the same usage, is not repeated here

To be continued

Guess you like

Origin www.cnblogs.com/Agnostida-Trilobita/p/11018513.html