** It's been two weeks since school began ,aFang Every day is busy , Why are you busy ? It's because the computer CET-2 is imminent , Are there any and aFang The same Python Computer CET-2 ? If so , Then the following content is likely to help you , It doesn't matter if there's no report , Let's keep watching , It will be used one day !
First, let's look at the exam outline :
Outline of national computer level II Examination
2018 The annual examination outline is 2021 Annual examination outline .

Question Types
one ,1-10 Public basic questions
Generally difficult , And a lot of knowledge needs to be accumulated at ordinary times .
Classic questions :

* Binary tree medium 0 Node of ( Leaf node ) The total ratio is 2 One more node .
* Function can improve the modularity of function and the reuse rate of code .
* Jump structure does not belong to Python Language control structure .
two , String type and formatting
① Ergodic method >>>a = “CBA” >>> for i in range(1,len(a)+1): >>> print(a[-i],end="") ABC
② Slice method
>>>a=”1234” >>>print(a[::-1]) 4321
String operator :
x+y# Connect two strings x*n perhaps n*x# take x copy n second x in s# If x yes s Substring of , Then return True, Otherwise return False
String processing function and method :
function :
len(s)# Return string s Length of , You can also return the number of elements of other composite elements str(s)# Returns any type of s Corresponding string form chr(s)
# return Unicode code s Represents a single character ord(s)# Return single character s Corresponding Unicode code hex(s)# Returns an integer s String in hexadecimal form oct(s)
# Returns an integer s String in octal form
method :
str.lower()# The return string is str All characters in lowercase str.upper()# The return string is str All characters in uppercase str.split(sep=None)
# Returns a list , According to parameters sep Split , If it is missing, it defaults to space str.count(sub)# Return substring sub stay str Number of occurrences in str.replace(old,
new)#, All substrings old Are replaced with strings new str.center(width,fillchar)# String function ,fillchar Parameter optional str.
strip(chars)# Removes all specified characters from the beginning and end of the string str.join(iter)# stay iter Add one after each element of the variable str character string
Number formatting :
format() function
{ Serial number : fill alignment width Thousands separator ( that is ","), accuracy , type }.
Number formatting

three , List processing
1, Element de duplication
method :
>>>a=[1,2,1,1,4,6,6,1]#set() method , duplicate removal >>>new_a=list(set(a)) >>>print(new_a) [1,2,4,
6]
2, operator
>>>a=[1,2,1,1,1]# in operator >>>1 in a True >>>a=[1,2,1,1,1]# not in operator >>>1 not
in a False
four , jieba
jieba.lcut(s): Precise mode , Returns a word segmentation result of list type . jieba.lcut(s,cut_all=True):
Full mode , Returns a word segmentation result of list type , Redundancy exists . jieba.lcut_for_search(s): Search engine mode , Returns a word segmentation result of list type , Redundancy exists . for example :
import jieba s = ' I am Chinese, , I love my country .' print(jieba.lcut(s)) print(jieba.lcut(s,cut_all
=True)) print(jieba.lcut_for_search(s)) Output as : [' I ', ' yes ', ' China ', ' people ', ',', ' I ', ' love '
, ' I ', ' of ', ' motherland ', '.'] [' I ', ' yes ', ' China ', ' countrymen ', ',', ' I ', ' love ', ' I ', ' of ', ' motherland ', '.'
] [' I ', ' yes ', ' China ', ' people ', ',', ' I ', ' love ', ' I ', ' of ', ' motherland ', '.']
five , random
random.randint()# Random integer output random.uniform()# Random decimal output random.seed()# Random seed definition random.
choice()# Custom random library random.random()# Random output
six ,turtle Library application
1, Basic shape drawing fd+left/right/seth
2, Special graphics drawing ( five-pointed star , Sun flower , Clover , love )
Octagonal :
import turtle as t t.pensize(2) for i in range(8): t.fd(100) t.left(45)
five-pointed star :
import turtle as t # Import turtle Library and name alias t.title(" Draw five pointed stars ") # Set Sketchpad title t.setup(500,300)
# Set Sketchpad size t.fillcolor("red") # Set fill color t.pencolor("yellow") # Sets the color of the pen t.pensize(3) # Sets the width of the pen
t.speed(5) # set speed t.penup() # Lift the brush t.goto(-100,25) # Move to initial position t.pendown() # Put down the brush t.
begin_fill() # Start filling for i in range(5): # loop 5 second ( Pentagram by 5 Draw edges ) t.forward(200) # Draw line length 200 t
.right(144) # Turn right 144 degree t.end_fill() # Stop filling t.done # Stay in the end interface
seven , Word frequency statistics
1, With special symbols
2, No special symbols
3, No specific words
eight , prime number ( Prime number ) problem
1, Definition of prime and prime numbers
2, Outputs prime numbers in a specific range / prime number
3, Filter prime numbers from a set of data / Prime number
4, Eliminate prime numbers from a set of data / Prime number
nine , Special sequence printing
1, Arithmetic sequence
2, Proportional sequence
3, Fibonacci sequence
ten , Binary conversion problem
Remember, if it's an input number , need int() Convert to integer and then perform related operations .
dec( decimal system )—> bin( Binary )
dec( decimal system )—> oct( octal number system )
dec( decimal system )—> hex( hexadecimal )
>>>a=input() # Enter here 10 >>>bin_a=bin(int(a)) >>>bin_a 0b1010
eleven ,utf-8 Coding problem
1, Code to character chr
2, Character transcoding ord
twelve , Case operation
1, Vector product ( and )/ Point distance problem
2, Price volume discount ( Multi branch )
3, Graphic area calculation
4, Leap year judgment problem
5, 9*9 Printing of multiplication table
6, Circular structure printing diamond
7, Yanghui triangle
8, Find the longest word
9, exception handling
10, Odd even number problem
thirteen , Use of low frequency library
1, Time
2, calendar
3, math
fourteen , Guide library
import Pakage import Pakage as from Pakage import */ part ```**

Technology