Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions 110304 課堂作業 - 我要生女兒 張宸瑋.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"prob(girl.born) = 0.49\n",
"prob(boy.born) = 0.51\n",
"\n",
"import random\n",
"a = random.randrange(0, 100, 1) \n",
"\n",
"if a > 48 :\n",
" return child.count==1\n",
"elif a > 48 and child.count==1 :\n",
" return child.count+1\n",
"elif a > 48 and child.count==2 :\n",
" return child.count+1\n",
"elif child.count==3 :\n",
" print('end')\n",
"else a < 48 :\n",
" print('girl.born')\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
48 changes: 48 additions & 0 deletions 110304 課堂作業 - 網路爬蟲 張宸瑋.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import requests\n",
"import pandas as pd\n",
"from sqlalchemy import create_engine\n",
"\n",
"req = requests.get('http://tw.movies.yahoo.com/movieinfo_main.html/id=5644/AQI.json')\n",
"data = json.loads(req.content.decode('utf8'))\n",
"df = pd.DataFrame(data)\n",
"\n",
"engine = create_engine('sqlite:///:memory:')\n",
"df.to_sql('db_table', engine, index=False)\n",
"print(pd.read_sql_query('SELECT `Release Date` as `上映日期`, `Genres` as `類型`, \\\n",
"Run Time as `片長`, `Director` as `導演`, , `Actors` as `演員`, `Distribution Corporation` as `發行公司`, \\\n",
", `Official Website` as `官方網站`, `Synopsis` as `劇情介紹`, FROM `db_table` \\\n",
"order by CAST(`MOVIE` AS int) DESC', engine))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}