在 Unix 中 bash 是什麼?
請說明Python變數的設定規則
請說明Python中escape character的用法和列出常見的例子
設計程式時出現以下錯誤,請協助修正:
AttributeError Traceback (most recent call last)
<ipython-input-8-b9d8f89049c4> in <cell line: 1>()
----> 1 a.upper()
AttributeError: 'int' object has no attribute 'upper'
請Debug以下程式:
a = 235 # integer
b = "two three five" # string
c = True # boolean
d = (2, 3, 5) # tuple
e = [2, 3, 5] # list
f = {"two": 2, "three": 3, "five": 5} # dictionary
type(f)
a.upper()
請解釋以下的程式碼:
from math import log2
count_new = 0
count_york = 0
count_new_york = 0
for i,tok in enumerate(tokens):
if tok == "new":
count_new += 1
try:
next_tok = tokens[i+1]
if next_tok == "york":
count_new_york += 1
except IndexError:
pass
if tok == "york":
count_york += 1
p_new = count_new / len(tokens)
p_work = count_york / len(tokens)
p_new_york = count_new_york / len(tokens)
pmi = log2(p_new_york / (p_new * p_work))
print("p_new =", p_new)
print("p_york =", p_work)
print("p_new_york =", p_new_york)
print("pmi =", pmi)
請為以下的程式碼加上註解:
from math import log2
count_new = 0
count_york = 0
count_new_york = 0
for i,tok in enumerate(tokens):
if tok == "new":
count_new += 1
try:
next_tok = tokens[i+1]
if next_tok == "york":
count_new_york += 1
except IndexError:
pass
if tok == "york":
count_york += 1
p_new = count_new / len(tokens)
p_work = count_york / len(tokens)
p_new_york = count_new_york / len(tokens)
pmi = log2(p_new_york / (p_new * p_work))
print("p_new =", p_new)
print("p_york =", p_work)
print("p_new_york =", p_new_york)
print("pmi =", pmi)
請用Python畫出log2的圖形,並包含程式坐標軸與x=1
Remove the punctuations of a string using Python.
請改進以下程式碼:
from math import log2
count_new = 0
count_york = 0
count_new_york = 0
for i,tok in enumerate(tokens):
if tok == "new":
count_new += 1
try:
next_tok = tokens[i+1]
if next_tok == "york":
count_new_york += 1
except IndexError:
pass
if tok == "york":
count_york += 1
p_new = count_new / len(tokens)
p_work = count_york / len(tokens)
p_new_york = count_new_york / len(tokens)
pmi = log2(p_new_york / (p_new * p_work))
print("p_new =", p_new)
print("p_york =", p_work)
print("p_new_york =", p_new_york)
print("pmi =", pmi)
Please use traditional chinese in all the following response
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing