Skip to content

Commit

Permalink
Merge branch 'master' of github.com:shell909090/learn-python
Browse files Browse the repository at this point in the history
  • Loading branch information
shell909090 committed Sep 2, 2016
2 parents 4b0186c + 61d501a commit 65c77de
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions 101 - Python入门.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:3f01d8afe5e4058736825c9d2fba24aa92acfdf66455984101e8fc51c1113d81"
"signature": "sha256:73504c50c97244894316331261d63342606bbf0781143736571003a129871444"
},
"nbformat": 3,
"nbformat_minor": 0,
Expand Down Expand Up @@ -765,14 +765,14 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"Enter something : 123\n"
"Enter something : 1\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Length of the string is 3\n"
"Length of the string is 1\n"
]
},
{
Expand Down Expand Up @@ -825,29 +825,29 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"Enter something : 123\n"
"Enter something : 1\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Input is of sufficient length\n"
"Too small\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"stream": "stdout",
"text": [
"Enter something : 1\n"
"Enter something : 123\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Too small\n"
"Input is of sufficient length\n"
]
},
{
Expand Down Expand Up @@ -1591,8 +1591,8 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"-rw-r--r-- 1 shell shell 111 8\u6708 17 15:41 testmod.py\r\n",
"-rw-r--r-- 1 shell shell 333 8\u6708 17 15:41 testmod.pyc\r\n"
"-rw-r--r-- 1 shell shell 111 8\u6708 23 22:10 testmod.py\r\n",
"-rw-r--r-- 1 shell shell 333 8\u6708 23 22:10 testmod.pyc\r\n"
]
}
],
Expand Down Expand Up @@ -1769,9 +1769,9 @@
"import sys\n",
"shoplist = ['apple', 'mango', 'carrot', 'banana']\n",
"print('I have {} items to purchase.'.format(len(shoplist)))\n",
"sys.stdout.write('These items are:')\n",
"sys.stdout.write('These items are: ')\n",
"for item in shoplist:\n",
" sys.stdout.write(str(item))\n",
" sys.stdout.write(str(item) + ' ')\n",
"print('\\nI also have to buy rice.')\n",
"shoplist.append('rice')\n",
"print('My shopping list is now {0}'.format(shoplist))\n",
Expand All @@ -1781,8 +1781,8 @@
"print('The first item I will buy is {0}'.format(shoplist[0]))\n",
"olditem = shoplist[0]\n",
"del shoplist[0]\n",
"print('I bought the{0}'.format(olditem))\n",
"print('My shopping list is now{0}'.format(shoplist))"
"print('I bought the {0}'.format(olditem))\n",
"print('My shopping list is now {0}'.format(shoplist))"
],
"language": "python",
"metadata": {},
Expand All @@ -1792,14 +1792,14 @@
"stream": "stdout",
"text": [
"I have 4 items to purchase.\n",
"These items are:applemangocarrotbanana\n",
"These items are: apple mango carrot banana \n",
"I also have to buy rice.\n",
"My shopping list is now ['apple', 'mango', 'carrot', 'banana', 'rice']\n",
"I will sort my list now\n",
"Sorted shopping list is ['apple', 'banana', 'carrot', 'mango', 'rice']\n",
"The first item I will buy is apple\n",
"I bought theapple\n",
"My shopping list is now['banana', 'carrot', 'mango', 'rice']\n"
"I bought the apple\n",
"My shopping list is now ['banana', 'carrot', 'mango', 'rice']\n"
]
}
],
Expand Down Expand Up @@ -1940,7 +1940,8 @@
"print('characters 1 to 3 is {0}'.format(name[1:3]))\n",
"print('characters 2 to end is {0}'.format(name[2:]))\n",
"print('characters 1 to -1 is {0}'.format(name[1:-1]))\n",
"print('characters start to end is {0}'.format(name[:]))"
"print('characters start to end is {0}'.format(name[:]))\n",
"print('reversed characters is {0}'.format(name[::-1]))"
],
"language": "python",
"metadata": {},
Expand All @@ -1963,7 +1964,8 @@
"characters 1 to 3 is wa\n",
"characters 2 to end is aroop\n",
"characters 1 to -1 is waroo\n",
"characters start to end is swaroop\n"
"characters start to end is swaroop\n",
"reversed characters is pooraws\n"
]
}
],
Expand Down Expand Up @@ -2174,14 +2176,14 @@
" 'Matsumoto': 'matz@ruby-lang.org',\n",
" 'Spammer': 'spammer@hotmail.com'\n",
"}\n",
"print(\"Swaroop's address is\".format(ab['Swaroop']))\n",
"print(\"Swaroop's address is {}\".format(ab['Swaroop']))\n",
"del ab['Spammer']\n",
"print('\\nThere are {} contacts in the address-book\\n'.format(len(ab)))\n",
"print('There are {} contacts in the address-book'.format(len(ab)))\n",
"for name, address in ab.items():\n",
" print('Contact {} at {}'.format(name, address))\n",
"ab['Guido'] = 'guido@python.org'\n",
"if 'Guido' in ab:\n",
" print(\"\\nGuido's address is\".format(ab['Guido']))"
" print(\"Guido's address is {}\".format(ab['Guido']))"
],
"language": "python",
"metadata": {},
Expand All @@ -2190,15 +2192,12 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"Swaroop's address is\n",
"\n",
"Swaroop's address is swaroop@swaroopch.com\n",
"There are 3 contacts in the address-book\n",
"\n",
"Contact Swaroop at swaroop@swaroopch.com\n",
"Contact Matsumoto at matz@ruby-lang.org\n",
"Contact Larry at larry@wall.org\n",
"\n",
"Guido's address is\n"
"Guido's address is guido@python.org\n"
]
}
],
Expand Down Expand Up @@ -2405,7 +2404,7 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"<__main__.Person instance at 0x7f3a144a53b0>\n"
"<__main__.Person instance at 0x7f29412a8fc8>\n"
]
}
],
Expand Down Expand Up @@ -2872,7 +2871,7 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"-rw-r--r-- 1 shell shell 95 8\u6708 17 15:41 poem.txt\r\n"
"-rw-r--r-- 1 shell shell 95 8\u6708 23 22:10 poem.txt\r\n"
]
}
],
Expand Down Expand Up @@ -3079,14 +3078,14 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"Enter something --> ok\n"
"Enter something --> 123\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"You entered ok\n"
"You entered 123\n"
]
}
],
Expand Down

0 comments on commit 65c77de

Please sign in to comment.