python learning the next day - basic grammar

Because there is a certain java-based, spent two days finished school "Crossin programming classroom - Python Getting Started" (the address on one), followed by the code number of the code, I have made an impression

According to the party being introduced hand, ready to start "Byte of Python", which is "A Byte of Python" Address: https://bop.mol.uno/  or   https://learnku.com/docs/byte-of-python / 2018

The latter is an active enthusiast community python translation, typesetting little good point. Start the topic "" "" "" "" "" "" "" "" "" "

1 Comment    # sign indicates

  • Suppose explanation (or precondition / condition)
  • Explain important decisions
  • Explain important details
  • Explain the problem you want to solve
  • Explain the problem you're trying to overcome in the program, etc.

2, literals   

  Also known as the literal, the value can not be changed, such as 5,3.14, "nothing!"

3, digital

  Two types: integer and floating point

  • As an integer of 2, note that there is no long type, int integer type can be of any size
  • Float (Floats) 3.14 as special, 4.2E-4 E denotes a power of 10, i.e., 4.2 * 10 ^ 4

4, string

  • Character sequence is, in essence, is a string of words
  • Single and double quotes may represent a string
  • Free single and double quotation marks in the three, the three-character string in quotation marks can specify multiple
  • No char type
  • The string can not be changed, and the java final class String is similar

. 5, the format method, similar to the java usage log, with placeholders to be understood:

age = 20
name = 'Swaroop'
print('{0} was {1} years old when he wrote this book'.format(name, age))或
print('{} was {} years old when he wrote this book'.format(name, age))

. 6, Print () always \ n (newline) as the end of the output, the parameters can be specified to avoid the end, such as print ( 'a', end = ''), print ( 'a', end = '')

7, the escape sequence

\\: \ 
\ '   : ' 
\ n-: newline 
\ t: tab 
string end BOC \ represents continue to the next line, but do not add a line break

8, the variable for storing the contents

9, the identifier name

  Just hand: alphanumeric characters and underscores, numbers do not begin with case-sensitive, some of the weird name, do not explored

10, the logical and physical row lines

  python java point difference is the use of a semicolon, physical line is the line where your eyes can see, the logical line is the line of code is executed, strongly recommended a physical line corresponds to a logical line, that line of a code

11, indent

  python official recommended four spaces to indent, python NA braces, the same indentation to form a set of statements, called the statement block

12, the object - heavy concept

  everything is object, python is a pure object-oriented, numbers, strings, functions are objects

 

"" "" "" "" "" Today's study is over, in fact there are java-based, can be less than 20 minutes to memorize and understand

Tomorrow learning Operators and Expressions

 

Guess you like

Origin www.cnblogs.com/yb38156/p/12483409.html