20182213 Experiment 1 "Python Programming" Experiment Report

20182213 2019-2020-2 "Python Programming" Experiment 1 Report

Course: "Python Programming"
Class: 1822
Student ID: 20182213
Experiment Teacher: Wang Zhiqiang
Experiment Date: April 11, 2020
Required / Elective: Public Elective

1. Experimental content

1. Familiar with Python development environment;

2. Practice Python running and debugging skills;

3. Write programs to practice variables and types, strings, objects, indentation and comments, etc .;

4. Master git skills

2. Experimental process and results

1. Familiar with Pycharm and other development environments;

① Familiar with IDLE development environment, write a piece of code as shown in the figure and use IDLE development environment to run

② Familiar with Pycharm's development environment

③ Use visual studio code notepad tool to write

2. Master basic Python running and debugging skills;

Able to run and debug in Pycharm as shown in the figure:

Run and

debug

3. Master basic Python programming skills.
Mastered basic programming techniques (to give some examples):

  • Calculate string length len ()
  • Perform lower (), upper () method to convert case
  • Remove the characters at the beginning and end of the string: strip (), lstrio (), rstrip ()
  • Remove whitespace by default
  • Check if it is a sequence member, str in string
  • Calculate the maximum and minimum sequence length
  • Splice strings (add strings, use + to merge sequences, the same elements will not be removed, the set cannot be added, the sequence is punished, multiplying by n is equivalent to the addition of n sequences, the set cannot be multiplied, the tuple can be Multiplication can also be added)
  • String interception (split function split (separator, number of splits (not input means all splits) merge function join (iterable list tuples are available)) The string to be added can be retrieved by str.join ()
  • count () retrieves the number of occurrences of a string in another string, returns 0 if it does not exist, otherwise returns the number
  • str.count (sub {specified search substring} [, start {search start} [, end]]
  • str.find () retrieves whether the specified string exists, returns -1 if it does not exist, otherwise returns the index position of the first occurrence
  • str.find (sub {specified search substring} [, start {search start} [, end]] can distinguish between lfind search from the left, rfind search from the right
  • index () Retrieves whether it contains substrings
  • whether start / endswith () starts / ends a
    substring formatted string
    1. Use the% operator
  • -: Optional parameter, left-aligned, unsigned in front of positive numbers, plus sign in front of negative numbers
  • +: Align right
  • 0, m: (0, m) together means that there are a total of several digits, not enough to fill zeros
  • .n: how many decimal places are reserved
  • % exp: exp represents the item to be converted, if multiple items are used, tuples are used
    2. It is recommended to use the format () method of string objects
  • str.format(args)
  • The basic syntax of args is to replace the previous% with {} and:
  • {[index][:[[fill]align][sign][#][width][.percision][type]]}
  • fill characters in the blank space,
  • align (valid for numbers): <Left Align> Right Align = content is left aligned, and put the symbol to the right of the added content, centered on the angle bracket
  • sign: sign
  • #: Specify for binary octal hexadecimal plus prefix such as binary 0b
  • .precision retains the number of decimal places
  • type indicates the formatted data type

4. Program code is hosted in Code Cloud

3. Problems encountered during the experiment and the resolution process

Question number problem Solution
1 Repeated upload failures during upload to Code Cloud Delete other warehouses and upload a new warehouse within the class

Others (sentiment, thinking, etc.)

In the process of learning python, I have learned a lot of new knowledge. I understand that doing things cannot be accomplished overnight. If you study hard, you will gain. You will be proficient in diligence and frivolity. And harvest.

References

  • ["Python programming from entry to practice"]

  • ["Zero Basic Python"]

Guess you like

Origin www.cnblogs.com/Mellivorac/p/12734768.html