@author bingxian (Ongoing update …)
Day 1
INTRODUCTION
(copy by my IDE, so everything display in code’s way)
this is my Python study place and my study note
there will include major grammar of Python
the code will all be turn into annotation, you can recover the part of code you want to execute
the word in ‘[]’ is ths thoughts of me – bing_xian
# this is an annotation
'''
this is also an annotation
'''
'''
String
string is an sequence of char
the most important characteristic the String has in Python is it can search char in a inverted order
something like
```python
word = "hello world"
print(word[-1])
```
this code will end up with output : 'd'
```python
word = "1000c"
print(word[0:-1])
```
this code will end up with output : '1000'
'''
# print(" -- following is the test place of string -- \n")
#
# print("1.test of inverted order")
# word = "hello world"
# print("the last char of 'hello world' is : " + word[-1] + "\n")
#
# print("2.test of substring")
# num = "1000c"
# print("the '1000c''s substring from index '0' to index '-1' is : " + num[0:-1] + '\n')
#
# print("-- test of string has completed --")
'''
assignment
python's assignment is also special that it have following grammar
<variable_1>, <variable_2>, <variable_3>, ... = <expression_1>, <expression_2>, <expression_3>, ...
```python
x = 1
y = 2
x, y = y, x
```
this is the simple version of
```python
x = 1
y = 2
t = x
x = y
y = t
```
the emergence of this grammar will immensely simplify the code of Python
[too elegant]
'''
# print(" -- following is the test of annotation -- \n")
#
# x = 1
# y = 2
# x, y = y, x
#
# print("x = 1\ny = 2\n and when finishing execute x, y = y, x, we would find that : \nx = " + str(x) + "\ny = " +
# str(y) + "\n")
#
# print(" -- test of annotation has completed -- ")
'''
input() method
we can obtain the input from console by method : input()
this method will return a string, whatever input is
```python
tempStr = input("please input something ... : ")
print(tempStr)
```
result will be the input from console
'''
# tempStr = input("please input something ... : ")
# print("result is : "tempStr)
'''
branch statement
Python combine 'else' and 'if' into 'elif' if they been used constantly
```python
if <condition_1>:
<code_1>
elif <condition_2>:
<code_2>
...
else:
<code_N>
```
then the <code_1>, <code_2>, ..., <code_N> will be executed in given order
'''
# tempStr = '123'
# if tempStr[-1] in ['2', '1']:
# print("the last char of '123' is in the list ['2', '1']")
# elif tempStr[-1] in ['3']:
# print("the last char of '123' is in the list ['3']")
# else:
# print('something is going wrong')
'''
eval() method
this method is a great creation that it can turn string into code and execute!!!!!!!!
then it will output the result of this string expression
```python
x = 1
eval("x + 1")
eval("1.1 + 2.2")
```
result and 2 and 3.3
'''
# x = 1
# eval("x + 1")
# eval("1.1 + 2.2")
'''
print() method
print out the variable inside '()'
[so simple that its example is needless]
'''
# print("this is print() method")
'''
loop statement
grammar is :
while <condition>:
<code>
the <code> will be executed again and again till <condition> turns into 'false'
```python
condition = 1
while condition < 10:
print("condition = " + str(condition++))
condition = condition + 1
```
the variable 'condition' will keep adding up with 1 till it bigger than 10
'''
# condition = 1
# while condition < 10:
# print("condition = " + str(condition))
# condition = condition + 1
'''
keyword 'def'
'def' can make you define your own custom method
```python
def printOutNum():
print("i don't want to obey your order. hum!")
printOutNum()
```
[this method is tsundere ]
'''
# def printOutNum():
# print("i don't want to obey your order. hum!")
#
#
# printOutNum()