One , Completion (15 branch )
* use print() Function to add multiple strings ’How’,’are ’,’you’ Output them together , Statement is __Print(“How”,”are”,”you”)_.
* use input() Function will “ Please enter your name :” Statement output and get data from the keyboard , Statement is _input(“ Please enter your name :”)_.
* __ list _____, ___ tuple ____ yes Python Ordered data type of ;__ aggregate _____,__ Dictionaries _____ Is an unordered data type .
* testword=’hello, Python!’,testword[-4]= _h____.testword[2:5]=_ llo _
* Python Built in functions _count______ You can go back to the list , tuple , Dictionaries , aggregate , String and range The number of elements in the object .
* Python Built in functions _len______ _ You can go back to the list , tuple , Dictionaries , aggregate , String and range The number of all elements in the object .
* Python sentence list(range(1,10,3)) The implementation result is __[1,4,7]___________.
* sentence sorted([1, 2, 3], reverse=True) I mean _ Sort the numbers in the list from large to small , The return result is a list ___.
* Use in circulation __break__ Statement to jump out of the deep loop .
* expression [x for x in [1,2,3,4,5] if x<3] The value of is __[1,2]____.
* expression set([1, 1, 2, 3]) The value of is _{1,2,3}_____.
* To get two collections A and B Union of , stay Python Should be used in __| Symbol or union function __.
* in use import Statement to import a function , have access to ___as____ Statement to assign an alias to a function
Two , Judgment questions (10 branch )
* expression [1,2,3] And expression [2,3,1] identical . ( f )
* Python It's a cross platform approach , Open Source , Free advanced dynamic programming language . ( t)
* Python 3.x Fully compatible Python 2.x. ( f)
*
Python Keywords are not allowed as variable names , However, built-in function names are allowed as variable names , However, this changes the meaning of the function name , So this is not recommended .
(t)
* Execution statement from math import sin after , It can be used directly sin() function , for example sin(3).( t)
* Python Variable names are not case sensitive , therefore student and Student Is the same variable .( f )
* Variable parameters *args When a function is passed in, it is stored as a list . ( f)
* Known x = 3, Then execute the statement x+=6 after ,x The memory address of is unchanged . ( f)
* The query speed of dictionary is not as fast as list and tuple . ( f)
* Judge whether the following code segment is legal ( f)
>>>number = 5
>>>print(number + ”is my lucky number.”)
Three , choice question (10 branch )
* Python Slicing of list data type elements in is very powerful , For lists mylist=[1,2,3,4,5,6,7,8,9], The following operation is correct ( B).
A,mylist[1:9:0] B,mylist[1:9:2] C,mylist(6:-9:-2)
D,mylist[10::]
* The highest priority operator is ( C).
A,is B,* C,** D,+
3. About Python Function description , The mistake is that ( B).
A. A function is a reusable group of statements
B. You need to provide the same parameters as input each time you use the function
C. Function is called by function name
D. A function is a group of statements with specific functions
4. About Python In the description of global variables and local variables , The mistake is that ( D).
A. Local variables are created and used inside functions , The variable is released after the function exits
B. Global variables generally refer to variables defined outside functions
C. use global After the reserved word declaration , Variables can be used as global variables
D. When the function exits , Local variables still exist , The next function call can continue to use
5. The incorrect writing of the open file is ( C).
A,f=open(‘test.txt’,’r’) B,with open(‘test.txt’,’r’) as f
C,f= open(‘C:\Apps\test.txt’,’r’) D,f= open(r‘C:\Apps\test.txt’,’r’)
6. About Python In the description of cyclic structure , The mistake is that ( D).
A. continue End this cycle only
B. The traversal structure in the traversal loop can be a string , file , Combined data types and range() Functions, etc
C. Python adopt for,while Constructing circular structure with equal reserved words
D. break Used to end the current statement , But do not jump out of the current loop
7. About Python In the description of the list , The mistake is that ( A).
A. The length and content of the list can be changed , But the element type must be the same
B. You can operate the membership of the list , Length calculation and slicing
C. The list can be indexed with both the forward increasing sequence number and the reverse decreasing sequence number
D. You can use the comparison operator ( as > or < etc. ) Compare the list
8.Python Data structure is divided into variable type and immutable type , The following are immutable types ( A).
A, Key in dictionary B, list C, aggregate D, Dictionaries
9. About Python In the description of the file open mode , The mistake is that ( D).
A. read only mode r
B. Overlay write mode w
C. Append write mode a
D. Create write mode n
10. In the following variable names , Not in line with Python What are the naming rules of language variables ( C).
A. keyword_33
B. keyword33_
C. 33_keyword
D. _33keyword
Four , Programming questions ( common 4 topic ,65 branch )
1, Programming , use * Print an isosceles right triangle as shown below , Take a screenshot of the test results .(15 branch )
*
* *
* * *
* * * *
for i in range(1,5):
for j in range(1,i+1):
print("*",end="")
print()
2, Write a number guessing game .(20 branch )
Required use random Modular randint() function
Random generation 20 Numbers within , The user has five chances to enter the guessed number from the keyboard , Guess big tip guess big , Guess tips guess small , If you guess correctly within the specified number of times, exit the program , Otherwise, continue to guess until the number of times exhausted . Test results
screenshot .
from random import randint
number = randint(1,20)
for i in range(5):
guess = int(input(" Please enter the number you guessed :"))
if guess > number:
print(" It's big ")
elif guess < number:
print(" It's small ")
else:
print(" bingo ")
break
3, Class and inheritance
(1) Create a Person class , Initialize the name in the constructor name, Age age attribute , Create a get_name Method to get the name of the person , With return value get_age Function to get the age of a person ;(15 branch )
class Person:
def __init__(self,name,age):
self.name = name
self.age = age
def get_name(self):
return self.name
def get_age(self):
return self.age
(2) establish Student Class inheritance Person Class properties and methods , In the constructor, call the constructor of the base class to initialize the common. name,age attribute , And will Student Class unique performance attributes course( Including language , mathematics , Three grades in English ) Initialize . Create a get_MaxScore Method is used to return the 3 In a subject
Highest score . Use examples
s1 = Student(‘ Xiao Ming ’,18,[93,68,76]) Yes Student Class , And output the result , Take a screenshot of the result .(15 branch )
class Student(Person):
def __init__(self,name,age,score):
Person.__init__(self,name,age)
self.score = score
def get_MinScore(self):
self.score.sort()
return self.score[-1]
s1 = Student(" Xiao Ming ",18,[93,68,76])
print(s1.get_name())
print(s1.get_age())
print(s1.get_MinScore())
Technology
Daily Recommendation