*Use print() for debug, The content inside ()could be ”or “”.

new line character \n

backslash=escape charcter \

for multiple text use triple quotes “””
*Difference between Interactive mode with file:there is a difference between returning a value and printing a value. There’s also a difference in how these things behave depending on whether you’re running them from a file or from interactive mode. In interactive mode, you’ll see values that get printed and also any returned values (even when they aren’t printed).

Function

  • len()  int can’t counted, “”=0 length of strings
  • [0] …. [9] subscript operator, indexing operator, count from left use positive, count from right use nagative
  • range[0,10,2] = 2,4,6,8
  • slice operation// “felix”[0:3]  …fel
  • f-strings f”who’s a cute {animal}?” f for formating
  • int() conver the value into an integer
  • str() turn integer to string
  • Boolean Operations : and or not
  • \ escape character

Opperations on lists

  • what : sequence types:strings/listes. They could wrkd for these operation: indexing, slicing, len.
  • Difference btw string and list: list is mutable(changable);strings is immutable (uchangable, but could be replaced). Mutable and immutable is two different data type.
  • append: plus to the end
  • extend:inserting several items(list or characters) to the end
  • reverse:turn a list back to front
  • sort:into alphabetical order

Augmented assignment+While Loops

n=n+1   n+=1    //n plus equals 1. b//!!!after +there is no blank.

The latter is called an augmented assignment statment, because it’s an assignment but it augments the exiting value rather than replacing it. Augmented assignment also works with all of the other arithmetic operators.

Aim: Use Python to do date analysis is using loops! We could use the initial code, but also use the method above the hood.

MAP:join—Find—Replace—Practice:Silly.py(words)

Joining

// method for building a string out of a list strings.

” “.join(words)

Find & Replace

Random.choice

Style & Structure

map:Pycodestyle-(find problem of too long)-(to solve)-multi-line strings-(why”” “”in[] work)-Explit line joining

Py code  style

Good code style could use this guide.

How to install: pip install pycodestyle

//for python3 use// pip3 install pycodestyle

#Test Code# When submit project, it should be checked and corrected via pycodestyle.

Multi-line strings

limit: to fit the screen 79/72 (guide)

Explicit line-joining

Breakfast bot

map: input–lower

input could only be string.

message.lower()  return a copy of the string with all coverted to lowercase

 

Command

Ctrl+C    stop programe//break out the infinate loop//Keyboard Interrupt

Error

Traceback…what last error happend

EOL stands fo End of Line.// ref mult-line string

Vocaubulary

concatenation:  link in a chain

Resoucese

Python Documentation: the method can used on strings