Python 3.3 Tutorial Notes - 1:Basic

1. "/": Division, always return float
2. "//": Floor division, return integer
3. "%": Reminder, return integer
 
1. "**": Power
 

1. Interactive mode, "_" means the value of the last printed expression. "_" is read only.

 

1. Complex number, use "j" or "J" to indicate the imaginary part -- "5+3j"

 

1. "..." And '...' are the same in Python

2."\" can be used to escape quotes

3. '"Yes"' will print out "Yes".

4. r"....", mean no escape in the string.

5. '"""..."""' or "'''...'''" to indicate a multiple line string. To avoid this, add "\" at the end of the line

6. String concatenation: "+" or side by side two string literals next to each other.

7. String repeat: <repeat times> * <the string>

8. String[i], the i-th char in string. Negative means from the end to the beginning.

9. String slicing: Str[0:2], 0 is included, 2 is excluded. Str[:j]: From beginning to j but not include j. Str[k:], from k to the end.

10. Python string is immutable

 

1. List: a=[1, 2, 3]
2. the type of element could be different: b=[1, 'a', 5.3]
3. string is immutable, list is mutable. For list, assign to a slice is also correct: a[3:5]=["hello", "world"]

1. Multiple-assignment: a,b=0,1
2. The right-hand expressions evaluate BEFORE assignment
3. All right-hand expressions evaluated from left to right.

1. Anything not zero means true in a place where boolean is expected

1. Indentation is important. It is the way to group statements.
2. When a compound statement is entered interactively, it must be followed by a blank line to indicate completion (since the parser cannot guess when you have typed the last line).
3. Note that each line within a basic block must be indented by the same amount.

1. print(), to avoid new line, use "end" argument: print(b, end=',')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值