2. The National Computer Level Two Python Exam-Basic Operation Questions (1)

important:

  • The code is displayed in the form of a picture. The red box is the test code in the exam , which is the code we need to supplement. The rest of the code will be given in the exam. We need to fill in the blank area by ourselves and run it correctly;
  • Only 12 sets of operation questions before the Computer Level 2 Python Exam in March 2020 are included, and the subsequent updated questions are not included in the content of the article.

1. There is a file PY101.py in the candidate's folder, please write the code to replace the horizontal line, do not modify other codes, and realize the following functions: keyboard input positive integer n, output n to the screen as required, format requirement: width 20 Characters, filled with sincerity characters, right-justified, with thousands separator. If the input positive integer exceeds 20 digits, it will be output according to the real length.

For example: keyboard input positive integer n is 1234, screen output ---------------1,234

Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

2. There is a file PY101.py in the candidate's folder, please write the code to replace the horizontal line, and do not modify other codes to achieve the following function: randomly select a mobile phone brand to output on the screen.
Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

3. There is a file PY101.py in the candidate's folder. Please write the code to replace the horizontal line to achieve the following functions: input 4 numbers from the keyboard, and each number is separated by a space, corresponding to the variables x0, y0, x1, y1. Calculate the distance between two points (x0, y0) and (x1, y1), and output this distance on the screen with 2 decimal places.
For example: keyboard input: 013 5 screen output: 5.00

Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

4. There is a file PY101.py in the candidate's folder, please write the code to replace the horizontal line, do not modify other codes, to achieve the following functions: keyboard input string s, output s to the screen as required, format requirements: width 20 Character, equal sign character = padding, center-aligned. If the input string exceeds 20 characters, all are output.
For example: keyboard input string s is "PYTH0N", screen output
=======PYTH0N======
Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

5. There is a file PY101.py in the candidate's folder, please write the code to replace the horizontal line, do not modify other codes, to achieve the following functions: keyboard input positive integer n, output n to the screen as required, format requirements: width 15 Characters, the right of the number is aligned, and the insufficient part is filled with *.
For example: keyboard input positive integer n is 1234, screen output *********1234

Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

6. There is a file PY101.py in the candidate's folder, please write the code to replace the horizontal line, do not modify other codes, and realize the following functions: keyboard input positive integer n, output n to the screen as required, format requirement: width 14 Characters, the number is aligned in the middle, and the insufficient part is filled with =. .
For example: keyboard n is a positive integer 1234, 1234 ==== ==== screen output
Tip: We recommend using Python IDE IDLE to write, debug and verification procedures provided by this machine.

7. There is a file PY101.py in the candidate's folder, please write the code to replace the horizontal line, do not modify other codes, to achieve the following functions: keyboard input positive integer n, output n to the screen as required, format requirements: width 25 Character, equal sign character (=) padding, right-justified, with thousands separator. If the input positive integer exceeds 25 digits, it will be output according to the real length. .
For example: n is a positive integer keyboard 1234, a screen 1234 output ================

Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

8. Obtain a number entered by the user, output the number with a width of 30 characters, hexadecimal, centered, lowercase letters, and use double quotation marks (") to fill extra characters. Please complete the code in PY101.py.
Tip: It is recommended to use Programs for writing, debugging and verifying in IDLE, a Python integrated development environment provided by this machine.

9. There is a file PY101.py in the candidate's folder. Fill in the code at the horizontal line to complete the following functions. The program receives five numbers entered by the user, separated by commas. These numbers are output in the order of input, each number occupies 10 characters width, right-aligned, and all numbers are displayed on the same line.

For example: input:
23, 42, 543, 56, 71

Output:
23 42 543 56 71

Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

10.10 There is a file PY101.py in the candidate's folder. Fill in the code at the horizontal line to complete the following functions. Receive user input-a positive integer less than 20, displayed on the screen in increments from 01 to the positive integer line by line, the width of the digital display is 2, fill in 0 in the insufficient position, add a space after it, and then display'>' The number of'>' is equal to the number at the beginning of the line.

E.g:

enter:

3

Output:

01>
02>>
03>>>
Tip: It is recommended to use the Python integrated development environment IDLE provided by this machine to write, debug and verify programs.

 

 

Guess you like

Origin blog.csdn.net/weixin_44940488/article/details/115315510