chore(i18n,learn): processed translations (#45313)

This commit is contained in:
camperbot
2022-03-02 20:56:06 +05:30
committed by GitHub
parent 339c6713d2
commit 27cfaf178c
58 changed files with 778 additions and 676 deletions

View File

@ -10,14 +10,9 @@ dashedName: arithmetic-formatter
このプロジェクトは [Replit スターターコード](https://replit.com/github/freeCodeCamp/boilerplate-arithmetic-formatter)を使用して作業を行います。
Python カリキュラムの対話式教育コンテンツを引き続き開発中です。 現在、下記の freeCodeCamp.org YouTube チャンネルで、このプロジェクトの完了に必要なすべての知識について説明する動画をいくつか公開しています。
- [「みんなで Python」ビデオコース](https://www.freecodecamp.org/news/python-for-everybody/) (14 時間)
- [「Python を学ぶ」ビデオコース](https://www.freecodecamp.org/news/learn-python-video-course/) (10 時間)
# --instructions--
小学校の算数では計算問題を解きやすくるために縦書きにすることが多くあります。 たとえば「235 + 52」を次のように記述します。
Students in primary school often arrange arithmetic problems vertically to make them easier to solve. For example, "235 + 52" becomes:
```py
235
@ -25,17 +20,17 @@ Python カリキュラムの対話式教育コンテンツを引き続き開発
-----
```
計算問題を表す文字列のリストを受け取り、問題を縦書きに整形して返す関数を作成してください。 この関数はオプションで第 2 引数を受け取る必要があります。 第 2 引数が `True` に設定されている場合は、解答を表示する必要があります。
Create a function that receives a list of strings that are arithmetic problems and returns the problems arranged vertically and side-by-side. The function should optionally take a second argument. When the second argument is set to `True`, the answers should be displayed.
## 例
関数呼び出し:
Function Call:
```py
arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])
```
出力:
Output:
```py
32 3801 45 123
@ -43,13 +38,13 @@ arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])
----- ------ ---- -----
```
関数呼び出し:
Function Call:
```py
arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"], True)
```
出力:
Output:
```py
32 1 9999 523
@ -60,35 +55,35 @@ arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"], True)
## ルール
入力された問題が正しく整形されている場合、この関数は正しい変換結果を返します。それ以外の場合は、**ユーザーにとって意味のあるエラーを記述した****文字列**を返します。
The function will return the correct conversion if the supplied problems are properly formatted, otherwise, it will **return** a **string** that describes an error that is meaningful to the user.
- エラーを返す場合:
- 関数に入力した**問題の数が多すぎる**場合。 上限を **5** つとし、それを超える場合は `Error: Too many problems.` (エラー: 問題が多すぎます) を返します。
- 関数が受け取ることのできる適切な演算子は**足し算**と**引き算**です。 掛け算と割り算はエラーを返します。 この箇条書きで指示していない他の演算子についてはテストする必要はありません。 次のようなエラーを返します: `Error: Operator must be '+' or '-'.` (エラー: '+' または '-' の演算子を使用してください)。
- 数値 (オペランド) にはそれぞれ数字のみを含める必要があります。 数値以外の場合、関数は次のエラーを返します: `Error: Numbers must only contain digits.` (エラー: 数値には数字のみを含める必要があります)。
- それぞれのオペランド (演算子の両側の数値) の幅は最大 4 桁です。 それ以外の場合は、次のようなエラー文字列を返します: `Error: Numbers cannot be more than four digits.` (エラー: 数値は 4 桁以内にする必要があります)。
- ユーザーが問題を正しい形式で入力した場合は、次のルールに従って変換結果を返します。
- 演算子と、2 つのオペランドのうち最も長いオペランドとの間に、スペースを 1 つ含めます。演算子は 2 つ目のオペランドと同じ行に表示し、両方のオペランドは入力されたとおりの順序で表示します (1 つ目のオペランドを上側に、2 つ目のオペランドを下側に表示します)。
- 数値は右揃えにする必要があります。
- それぞれの問題の間に 4 つのスペースが必要です。
- それぞれの問題の一番下にダッシュが必要です。 ダッシュは、各問題の全体の長さに沿った長さにする必要があります (上の表示例を参考にしてください)
- Situations that will return an error:
- If there are **too many problems** supplied to the function. The limit is **five**, anything more will return: `Error: Too many problems.`
- The appropriate operators the function will accept are **addition** and **subtraction**. Multiplication and division will return an error. Other operators not mentioned in this bullet point will not need to be tested. The error returned will be: `Error: Operator must be '+' or '-'.`
- Each number (operand) should only contain digits. Otherwise, the function will return: `Error: Numbers must only contain digits.`
- Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be: `Error: Numbers cannot be more than four digits.`
- If the user supplied the correct format of problems, the conversion you return will follow these rules:
- There should be a single space between the operator and the longest of the two operands, the operator will be on the same line as the second operand, both operands will be in the same order as provided (the first will be the top one and the second will be the bottom.
- Numbers should be right-aligned.
- There should be four spaces between each problem.
- There should be dashes at the bottom of each problem. The dashes should run along the entire length of each problem individually. (The example above shows what this should look like.)
## 開発
`arithmetic_arranger.py` でコードを記述してください。 開発には `main.py` を使用して `arithmetic_arranger()` 関数をテストすることができます。 「実行」ボタンをクリックすると `main.py` が実行されます。
Write your code in `arithmetic_arranger.py`. For development, you can use `main.py` to test your `arithmetic_arranger()` function. Click the "run" button and `main.py` will run.
## テスト
このプロジェクトの単体テストは `test_module.py` にあります。 `test_module.py` のテストを `main.py` で実行できるようになっています。 「実行」ボタンを押すと自動的にテストが実行されます。 または、コンソールに `pytest` と入力してテストを実行することもできます。
The unit tests for this project are in `test_module.py`. We are running the tests from `test_module.py` in `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button. Alternatively you may run the tests by inputting `pytest` in the console.
## 提出
プロジェクトの URL をコピーし、下記に提出してください。
Copy your project's URL and submit it below.
# --hints--
計算問題を正しく整形し、すべてのテストに合格する必要があります。
It should correctly format an arithmetic problem and pass all tests.
```js

View File

@ -10,29 +10,23 @@ dashedName: budget-app
このプロジェクトは [Replit スターターコード](https://replit.com/github/freeCodeCamp/boilerplate-budget-app)を使用して作業を行います。
Python カリキュラムの対話式教育コンテンツを引き続き開発中です。 現在、下記の freeCodeCamp.org YouTube チャンネルで、このプロジェクトの完了に必要なすべての知識について説明する動画をいくつか公開しています。
- [「みんなで Python」ビデオコース](https://www.freecodecamp.org/news/python-for-everybody/) (14 時間)
- [「Python を学ぶ」ビデオコース](https://www.freecodecamp.org/news/learn-python-video-course/) (10 時間)
# --instructions--
`budget.py``Category` クラスを完成させてください。 *食費*、*服飾費*、*娯楽費*など、さまざまな予算のカテゴリに応じてオブジェクトをインスタンス化できるようにする必要があります。 オブジェクトを作成したら、カテゴリの名前をオブジェクトに渡します。 クラスには、リスト形式の帳簿となる `ledger` というインスタンス変数が必要です。 クラスには次のメソッドも含める必要があります。
Complete the `Category` class in `budget.py`. It should be able to instantiate objects based on different budget categories like *food*, *clothing*, and *entertainment*. When objects are created, they are passed in the name of the category. The class should have an instance variable called `ledger` that is a list. The class should also contain the following methods:
- `deposit` (預け入れ) メソッド。金額と説明を受け取ります。 説明がない場合は、デフォルトで空の文字列にします。 このメソッドでは、`{"amount": amount, "description": description}` という形式で帳簿リストの末尾にオブジェクトを追加する必要があります。
- `withdraw` (引き出し) メソッド。`deposit` メソッドに似ていますが、渡された金額を負数として帳簿に保存する必要があります。 十分な資金がない場合は、帳簿に何も追加しないでください。 このメソッドは、引き出しが行われた場合は `True` を返し、それ以外の場合は `False` を返す必要があります。
- `get_balance` (残高確認) メソッド。発生した入出金に基づいて予算カテゴリの現在の残高を返します。
- `transfer` (送金) メソッド。引数として金額と別の予算カテゴリを受け取ります。 このメソッドでは、金額と "Transfer to [Destination Budget Category]" ([送金先の予算カテゴリ] への送金) という記述からなる出金を追加する必要があります。 このメソッドによって、金額と "Transfer to [Destination Budget Category]" という記述からなる入金額が他の予算カテゴリに追加されます。 十分な資金がない場合は、どちらの帳簿にも何も追加しないでください。 このメソッドは、送金が行われた場合は `True` を返し、それ以外の場合は `False` を返す必要があります。
- `check_funds` (資金確認) メソッド。引数として金額を受け取ります。 金額が予算カテゴリの残高よりも大きい場合は `False` を返し、それ以外の場合は `True` を返します。 このメソッドは `withdraw` メソッドと `transfer` メソッドの両方で使用する必要があります。
- A `deposit` method that accepts an amount and description. If no description is given, it should default to an empty string. The method should append an object to the ledger list in the form of `{"amount": amount, "description": description}`.
- A `withdraw` method that is similar to the `deposit` method, but the amount passed in should be stored in the ledger as a negative number. If there are not enough funds, nothing should be added to the ledger. This method should return `True` if the withdrawal took place, and `False` otherwise.
- A `get_balance` method that returns the current balance of the budget category based on the deposits and withdrawals that have occurred.
- A `transfer` method that accepts an amount and another budget category as arguments. The method should add a withdrawal with the amount and the description "Transfer to [Destination Budget Category]". The method should then add a deposit to the other budget category with the amount and the description "Transfer from [Source Budget Category]". If there are not enough funds, nothing should be added to either ledgers. This method should return `True` if the transfer took place, and `False` otherwise.
- A `check_funds` method that accepts an amount as an argument. It returns `False` if the amount is greater than the balance of the budget category and returns `True` otherwise. This method should be used by both the `withdraw` method and `transfer` method.
予算オブジェクトを出力するときは次のように表示する必要があります。
When the budget object is printed it should display:
- 30 文字のタイトル行。`*` 文字を並べて 1 行とし、中央にカテゴリの名前を置きます。
- 帳簿にある品目のリスト。 各行に説明と金額を表示します。 説明の最初の 23 文字を表示し、その後に金額を表示します。 金額は右揃えで、小数点以下 2 桁までを含み、最大 7 文字まで表示します。
- カテゴリの合計を表示する行。
- A title line of 30 characters where the name of the category is centered in a line of `*` characters.
- A list of the items in the ledger. Each line should show the description and amount. The first 23 characters of the description should be displayed, then the amount. The amount should be right aligned, contain two decimal places, and display a maximum of 7 characters.
- A line displaying the category total.
出力の例を次に示します。
Here is an example of the output:
```bash
*************Food*************
@ -43,13 +37,13 @@ Transfer to Clothing -50.00
Total: 923.96
```
`Category` クラスの他に、カテゴリのリストを引数に取る `create_spend_chart` という関数を (クラスの外で) 作成してください。 この関数は棒グラフとなる文字列を返す必要があります。
Besides the `Category` class, create a function (outside of the class) called `create_spend_chart` that takes a list of categories as an argument. It should return a string that is a bar chart.
グラフでは、関数に渡された各カテゴリについて、その出費の割合を表示する必要があります。 出費の割合は、引き出し額でのみ計算する必要があり、預け入れ額では計算しません。 グラフの左下には 0 100 のラベルを付ける必要があります。 棒グラフの「棒」は文字 "o" を使用して作成する必要があります。 各棒の高さは最も近い 10 に切り下げる必要があります。 グラフの下の水平線は最後の棒からスペース 2 つ分だけ離す必要があります。 各カテゴリ名は棒の下に垂直に記述する必要があります。 一番上には "Percentage spent by category" (カテゴリ別の出費の割合) というタイトルを付ける必要があります。
The chart should show the percentage spent in each category passed in to the function. The percentage spent should be calculated only with withdrawals and not with deposits. Down the left side of the chart should be labels 0 - 100. The "bars" in the bar chart should be made out of the "o" character. The height of each bar should be rounded down to the nearest 10. The horizontal line below the bars should go two spaces past the final bar. Each category name should be written vertically below the bar. There should be a title at the top that says "Percentage spent by category".
この関数は最大 4 つのカテゴリでテストされます。
This function will be tested with up to four categories.
次の出力例を参考にして、出力の間隔を例と正確に合わせてください。
Look at the example output below very closely and make sure the spacing of the output matches the example exactly.
```bash
Percentage spent by category
@ -75,23 +69,23 @@ Percentage spent by category
g
```
このプロジェクトの単体テストは `test_module.py` にあります。
The unit tests for this project are in `test_module.py`.
## 開発
`budget.py` でコードを記述してください。 開発には `main.py` を使用して `Category` クラスをテストすることができます。 「実行」ボタンをクリックすると `main.py` が実行されます。
Write your code in `budget.py`. For development, you can use `main.py` to test your `Category` class. Click the "run" button and `main.py` will run.
## テスト
すでに `test_module.py` から `main.py` にテストをインポートしてあります。 「実行」ボタンを押すと自動的にテストが実行されます。
We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button.
## 提出
プロジェクトの URL をコピーし、freeCodeCamp に提出してください。
Copy your project's URL and submit it to freeCodeCamp.
# --hints--
Category クラスを作成し、すべてのテストに合格する必要があります。
It should create a Category class and pass all tests.
```js

View File

@ -10,37 +10,31 @@ dashedName: polygon-area-calculator
このプロジェクトは [Replit スターターコード](https://replit.com/github/freeCodeCamp/boilerplate-polygon-area-calculator)を使用して作業を行います。
Python カリキュラムの対話式教育コンテンツを引き続き開発中です。 現在、下記の freeCodeCamp.org YouTube チャンネルで、このプロジェクトの完了に必要なすべての知識について説明する動画をいくつか公開しています。
- [「みんなで Python」ビデオコース](https://www.freecodecamp.org/news/python-for-everybody/) (14 時間)
- [「Python を学ぶ」ビデオコース](https://www.freecodecamp.org/news/learn-python-video-course/) (10 時間)
# --instructions--
このプロジェクトでは、オブジェクト指向プログラミングを使用して、Rectangle クラスと Square クラスを作成します。 Square クラスは Rectangle のサブクラスであり、メソッドと属性を継承する必要があります。
In this project you will use object oriented programming to create a Rectangle class and a Square class. The Square class should be a subclass of Rectangle and inherit methods and attributes.
## Rectangle クラス
Rectangle オブジェクトが作成されるときは、`width` 属性と `height` 属性で初期化する必要があります。 クラスには、次のメソッドも含める必要があります。
When a Rectangle object is created, it should be initialized with `width` and `height` attributes. The class should also contain the following methods:
- `set_width`
- `set_height`
- `get_area`: 面積を返します (`width * height`)
- `get_perimeter`: 外周を返します (`2 * width + 2 * height`)
- `get_diagonal`: 対角線を返します(`(width ** 2 + height ** 2) ** .5`)
- `get_picture`: "\*" の行を使用して図形を表す文字列を返します。 行数は高さと等しく、各行の"\*"の数は幅と等しくする必要があります。 各行の末尾に改行 (`\n`) が必要です。 幅または高さが 50 より大きい場合は、文字列 "Too big for picture." を返す必要があります。
- `get_amount_inside`: 引数として別の図形 (正方形または長方形) を受け取ります。 渡された図形が、その図形の中に何個収まるかを返します (回転はしません)。 たとえば、幅が 4 で高さが 8 の長方形には、一辺が 4 の正方形が 2つ収まります。
- `get_area`: Returns area (`width * height`)
- `get_perimeter`: Returns perimeter (`2 * width + 2 * height`)
- `get_diagonal`: Returns diagonal (`(width ** 2 + height ** 2) ** .5`)
- `get_picture`: Returns a string that represents the shape using lines of "\*". The number of lines should be equal to the height and the number of "\*" in each line should be equal to the width. There should be a new line (`\n`) at the end of each line. If the width or height is larger than 50, this should return the string: "Too big for picture.".
- `get_amount_inside`: Takes another shape (square or rectangle) as an argument. Returns the number of times the passed in shape could fit inside the shape (with no rotations). For instance, a rectangle with a width of 4 and a height of 8 could fit in two squares with sides of 4.
また、Rectangle のインスタンスを文字列として表現する場合は、`Rectangle(width=5, height=10)` のようにする必要があります。
Additionally, if an instance of a Rectangle is represented as a string, it should look like: `Rectangle(width=5, height=10)`
## Square クラス
Square クラスは Rectangle のサブクラスである必要があります。 Square オブジェクトが生成されるときは、一辺の長さを渡します。 `__init__` メソッドでは、一辺の長さを Rectangle クラスの `width` 属性と `height` 属性の両方に格納する必要があります。
The Square class should be a subclass of Rectangle. When a Square object is created, a single side length is passed in. The `__init__` method should store the side length in both the `width` and `height` attributes from the Rectangle class.
Square クラスは、Rectangle クラスのメソッドにアクセスできる必要があり、加えて `set_side` メソッドも含める必要があります。 Square のインスタンスを文字列として表現する場合は、`Square(side=9)` のようにする必要があります。
The Square class should be able to access the Rectangle class methods but should also contain a `set_side` method. If an instance of a Square is represented as a string, it should look like: `Square(side=9)`
また、Square クラスの `set_width` `set_height` メソッドでは、幅と高さの両方を設定する必要があります。
Additionally, the `set_width` and `set_height` methods on the Square class should set both the width and height.
## 使用例
@ -64,7 +58,7 @@ rect.set_width(16)
print(rect.get_amount_inside(sq))
```
上記のコードは次を返す必要があります。
That code should return:
```bash
50
@ -85,23 +79,23 @@ Square(side=4)
8
```
このプロジェクトの単体テストは `test_module.py` にあります。
The unit tests for this project are in `test_module.py`.
## 開発
`shape_calculator.py` でコードを記述してください。 開発には `main.py` を使用して `shape_calculator()` 関数をテストすることができます。 「実行」ボタンをクリックすると `main.py` が実行されます。
Write your code in `shape_calculator.py`. For development, you can use `main.py` to test your `shape_calculator()` function. Click the "run" button and `main.py` will run.
## テスト
すでに `test_module.py` から `main.py` にテストをインポートしてあります。 「実行」ボタンを押すと自動的にテストが実行されます。
We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button.
## 提出
プロジェクトの URL をコピーし、freeCodeCamp に提出してください。
Copy your project's URL and submit it to freeCodeCamp.
# --hints--
Rectangle クラスと Square クラスを作成し、すべてのテストに合格する必要があります。
It should create a Rectangle class and Square class and pass all tests.
```js

View File

@ -10,19 +10,13 @@ dashedName: probability-calculator
このプロジェクトは [Replit スターターコード](https://replit.com/github/freeCodeCamp/boilerplate-probability-calculator)を使用して作業を行います。
Python カリキュラムの対話式教育コンテンツを引き続き開発中です。 現在、下記の freeCodeCamp.org YouTube チャンネルで、このプロジェクトの完了に必要なすべての知識について説明する動画をいくつか公開しています。
- [「みんなで Python」ビデオコース](https://www.freecodecamp.org/news/python-for-everybody/) (14 時間)
- [「Python を学ぶ」ビデオコース](https://www.freecodecamp.org/news/learn-python-video-course/) (10 時間)
# --instructions--
帽子があり、その中に青いボールが 5 個、赤いボールが 4 個、緑のボールが 2 個入っているとします。 4 個のボールを無作為に取り出す場合、赤のボールが 1 個以上、緑のボールが 2 個含まれる確率は、いくらになりますか? 高度な数学を駆使して確率を計算することも可能ですが、多数の実験を実行しておおよその確率を推定するプログラムを記述する方が簡単です。
Suppose there is a hat containing 5 blue balls, 4 red balls, and 2 green balls. What is the probability that a random draw of 4 balls will contain at least 1 red ball and 2 green balls? While it would be possible to calculate the probability using advanced mathematics, an easier way is to write a program to perform a large number of experiments to estimate an approximate probability.
このプロジェクトでは、特定のボールを帽子から無作為に取り出す場合のおおよその確率を調べるプログラムを作成します。
For this project, you will write a program to determine the approximate probability of drawing certain balls randomly from a hat.
まず、`prob_calculator.py``Hat` クラスを作成してください。 このクラスは、帽子に入っている各色のボールの数を指定する可変個の引数を受け取る必要があります。 たとえば、次のどの方法でもクラスオブジェクトを作成することができます。
First, create a `Hat` class in `prob_calculator.py`. The class should take a variable number of arguments that specify the number of balls of each color that are in the hat. For example, a class object could be created in any of these ways:
```py
hat1 = Hat(yellow=3, blue=2, green=6)
@ -30,22 +24,22 @@ hat2 = Hat(red=5, orange=4)
hat3 = Hat(red=5, orange=4, black=1, blue=0, pink=2, striped=9)
```
帽子は常に、少なくとも 1 個のボールが入った状態で作成されます。 作成時に帽子オブジェクトに渡された引数を、`contents` インスタンス変数に変換する必要があります。 `contents` は、帽子に入っているボールごとにアイテムを 1 つずつ含む文字列のリストである必要があります。 リスト内の各アイテムは、その色のボール 1 個分を表す色の名前である必要があります。 たとえば、帽子が `{"red": 2, "blue": 1}` の場合、`contents` `["red", "red", "blue"]` になる必要があります。
A hat will always be created with at least one ball. The arguments passed into the hat object upon creation should be converted to a `contents` instance variable. `contents` should be a list of strings containing one item for each ball in the hat. Each item in the list should be a color name representing a single ball of that color. For example, if your hat is `{"red": 2, "blue": 1}`, `contents` should be `["red", "red", "blue"]`.
`Hat` クラスには `draw` メソッドが必要です。このメソッドは、帽子から取り出すボールの個数を示す引数を受け取ります。 draw メソッドは、`contents` からボールを無作為に取り除き、それらのボールを文字列のリストとして返す必要があります。 交換のできない壺の実験と同様に、取り出したボールは帽子に戻さないものとします。 取り出すボールの数が利用可能な数を超える場合は、すべてのボールを返してください。
The `Hat` class should have a `draw` method that accepts an argument indicating the number of balls to draw from the hat. This method should remove balls at random from `contents` and return those balls as a list of strings. The balls should not go back into the hat during the draw, similar to an urn experiment without replacement. If the number of balls to draw exceeds the available quantity, return all the balls.
次に、(`Hat` クラスの中ではなく) `prob_calculator.py``experiment` 関数を作成してください。 この関数は次の引数を受け取る必要があります。
Next, create an `experiment` function in `prob_calculator.py` (not inside the `Hat` class). This function should accept the following arguments:
- `hat`: 関数内でコピーする必要のあるボールを含む帽子オブジェクト。
- `expected_balls`: 実験で帽子から取り出そうとするボールの正確なグループを示すオブジェクト。 たとえば、青のボール 2 個と赤のボール 1 個を帽子から取り出す確率を調べるには、`expected_balls` `{"blue":2, "red":1}` に設定します。
- `num_balls_drawn`: 各実験で帽子から取り出すボールの数。
- `num_experiments`: 実行する実験の回数 (実験の回数が多いほど、おおよその確率の正確性が高まります)。
- `hat`: A hat object containing balls that should be copied inside the function.
- `expected_balls`: An object indicating the exact group of balls to attempt to draw from the hat for the experiment. For example, to determine the probability of drawing 2 blue balls and 1 red ball from the hat, set `expected_balls` to `{"blue":2, "red":1}`.
- `num_balls_drawn`: The number of balls to draw out of the hat in each experiment.
- `num_experiments`: The number of experiments to perform. (The more experiments performed, the more accurate the approximate probability will be.)
`experiment` 関数は、確率を返す必要があります。
The `experiment` function should return a probability.
たとえば、黒を 6 個、赤を 4 個、緑を 3 個含む帽子から 5 個のボールを取り出す場合に、赤のボールが少なくとも 2 個、緑のボールが少なくとも 1 個含まれる確率を求めたいとしましょう。 それには、`N` 回の実験を行い、赤のボールが少なくとも 2 個、緑のボールが少なくとも 1 個になった回数 `M` を数え、確率を `M/N` として推定します。 実験ではそれぞれ、指定されたボールの入った帽子の状態から始め、いくつかのボールを取り出し、期待されるボールを取り出したかどうかを確認します。
For example, let's say that you want to determine the probability of getting at least 2 red balls and 1 green ball when you draw 5 balls from a hat containing 6 black, 4 red, and 3 green. To do this, we perform `N` experiments, count how many times `M` we get at least 2 red balls and 1 green ball, and estimate the probability as `M/N`. Each experiment consists of starting with a hat containing the specified balls, drawing a number of balls, and checking if we got the balls we were attempting to draw.
上記の例で 2000 回の実験を行う場合は、`experiment` 関数を次のように呼び出します。
Here is how you would call the `experiment` function based on the example above with 2000 experiments:
```py
hat = Hat(black=6, red=4, green=3)
@ -55,27 +49,27 @@ probability = experiment(hat=hat,
num_experiments=2000)
```
この方法は無作為抽出に基づいているため、コードが実行されるたびに確率が多少変わります。
Since this is based on random draws, the probability will be slightly different each time the code is run.
*ヒント: `prob_calculator.py` の先頭ですでにインポートされているモジュールを使用することを検討してください。 `prob_calculator.py` の中で乱数シードを初期化しないでください。*
*Hint: Consider using the modules that are already imported at the top of `prob_calculator.py`. Do not initialize random seed within `prob_calculator.py`.*
## 開発
`prob_calculator.py` でコードを記述してください。 開発には `main.py` を使用してコードをテストすることができます。 「実行」ボタンをクリックすると `main.py` が実行されます。
Write your code in `prob_calculator.py`. For development, you can use `main.py` to test your code. Click the "run" button and `main.py` will run.
ボイラープレートには `copy` モジュールと `random` モジュール用の `import` ステートメントが含まれています。 これらをプロジェクトで使用することを検討してください。
The boilerplate includes `import` statements for the `copy` and `random` modules. Consider using those in your project.
## テスト
このプロジェクトの単体テストは `test_module.py` にあります。 すでに `test_module.py` から `main.py` にテストをインポートしてあります。 「実行」ボタンを押すと自動的にテストが実行されます。
The unit tests for this project are in `test_module.py`. We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button.
## 提出
プロジェクトの URL をコピーし、freeCodeCamp に提出してください。
Copy your project's URL and submit it to freeCodeCamp.
# --hints--
確率を正しく計算し、すべてのテストに合格する必要があります。
It should correctly calculate probabilities and pass all tests.
```js

View File

@ -10,27 +10,21 @@ dashedName: time-calculator
このプロジェクトは [Replit スターターコード](https://replit.com/github/freeCodeCamp/boilerplate-time-calculator)を使用して作業を行います。
Python カリキュラムの対話式教育コンテンツを引き続き開発中です。 現在、下記の freeCodeCamp.org YouTube チャンネルで、このプロジェクトの完了に必要なすべての知識について説明する動画をいくつか公開しています。
- [「みんなで Python」ビデオコース](https://www.freecodecamp.org/news/python-for-everybody/) (14 時間)
- [「Python を学ぶ」ビデオコース](https://www.freecodecamp.org/news/learn-python-video-course/) (10 時間)
# --instructions--
下記に示す 2 つの必須パラメーターと 1 つのオプションパラメーターを受け取る関数 `add_time` を記述してください。
Write a function named `add_time` that takes in two required parameters and one optional parameter:
- 12 時制形式の開始時刻 (末尾に AM または PM)
- 時数と分数で示される経過時間
- (オプション) 開始の曜日 (大文字小文字の記述は自由)
- a start time in the 12-hour clock format (ending in AM or PM)
- a duration time that indicates the number of hours and minutes
- (optional) a starting day of the week, case insensitive
関数は、経過時間を開始時刻に追加し、その結果を返す必要があります。
The function should add the duration time to the start time and return the result.
結果が翌日になる場合は、時刻の後に `(next day)` (翌日) を表示する必要があります。 結果が翌日以降になる場合は、時刻の後に `(n days later)` (n 日後) を表示する必要があります。ここで "n" は何日後かを示します。
If the result will be the next day, it should show `(next day)` after the time. If the result will be more than one day later, it should show `(n days later)` after the time, where "n" is the number of days later.
関数にオプションの開始曜日パラメーターが与えられた場合は、結果の曜日を出力に表示する必要があります。 出力する曜日は、時刻の後、「n 日後」の前に表示する必要があります。
If the function is given the optional starting day of the week parameter, then the output should display the day of the week of the result. The day of the week in the output should appear after the time and before the number of days later.
関数が扱うさまざまなケースの例を次に示します。 結果のスペースと句読点の表示に特に注意を払ってください。
Below are some examples of different cases the function should handle. Pay close attention to the spacing and punctuation of the results.
```py
add_time("3:00 PM", "3:10")
@ -52,23 +46,23 @@ add_time("6:30 PM", "205:12")
# Returns: 7:42 AM (9 days later)
```
Python ライブラリをインポートしないでください。 開始時刻は有効な時刻であると仮定します。 経過時間の分数は 60 未満の整数になりますが、時数は任意の整数になります。
Do not import any Python libraries. Assume that the start times are valid times. The minutes in the duration time will be a whole number less than 60, but the hour can be any whole number.
## 開発
`time_calculator.py` でコードを記述してください。 開発には `main.py` を使用して `time_calculator()` 関数をテストすることができます。 「実行」ボタンをクリックすると `main.py` が実行されます。
Write your code in `time_calculator.py`. For development, you can use `main.py` to test your `time_calculator()` function. Click the "run" button and `main.py` will run.
## テスト
このプロジェクトの単体テストは `test_module.py` にあります。 すでに `test_module.py` から `main.py` にテストをインポートしてあります。 「実行」ボタンを押すと自動的にテストが実行されます。
The unit tests for this project are in `test_module.py`. We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button.
## 提出
プロジェクトの URL をコピーし、freeCodeCamp に提出してください。
Copy your project's URL and submit it to freeCodeCamp.
# --hints--
正確に時間を追加し、すべてのテストに合格する必要があります。
It should correctly add times and pass all tests.
```js