Placeholder Image

字幕表 動画を再生する

AI 自動生成字幕
  • Hi everyone, my name is Giovanna Proença and today we're going to talk about Problem

    皆さん、こんにちは。私の名前はジョバンナ・プロエンサです。

  • Set Zero Playback Speed of CS50 Python.

    CS50 Pythonの再生速度をゼロにする。

  • So if you have any question about programming, if you want to know about more the career or other things, please check the description below where you can schedule a 30-minute free session with us, alright?

    プログラミングについて質問がある方、もっとキャリアについて知りたい方、その他のことを知りたい方は、以下の説明をご覧ください。

  • And before we start, I would like to emphasize that this video solution is made for those who have already completed the assignment and want to have a second view of the code, alright?

    そして、始める前に強調しておきたいのは、このビデオ・ソリューションは、すでに課題を終えていて、コードをもう一度見たい人のために作られているということだ。

  • We do not encourage plagiarism.

    私たちは盗作を奨励しません。

  • So let's just start.

    では、さっそく始めよう。

  • Here we have some people have a habit of speaking rather quickly and it'd be nice to slow them down.

    ここでは、早口で話す癖のある人がいるので、ゆっくり話してもらえると助かる。

  • So allow YouTube 0.75 playback speed or even by having them pause between words.

    そのため、YouTubeの再生速度を0.75にしたり、単語と単語の間に一時停止させたりすることもできる。

  • In a file called playback.py, implement a program in Python that prompts the user for input and then outputs the same input replacing each space with three periods.

    playback.pyというファイルに、ユーザーに入力を促し、同じ入力を3つのピリオドに置き換えて出力するプログラムをPythonで実装する。

  • So here we have the example we have here.

    だから、ここにある例がある。

  • Once we run the code, we're going to write a message to user and we're going to prompt the message with three periods instead of the white space, okay?

    コードを実行したら、ユーザーにメッセージを書き、空白の代わりに3つのピリオドでメッセージを促します。

  • So let's start thinking about the things that we need.

    だから、必要なものについて考え始めよう。

  • I already did here a pseudocode, alright?

    擬似コードはすでに書いたよ。

  • So basically we need to get input from the user, then we're going to change white space for three dots and then we're going to print the output.

    つまり、基本的にはユーザーから入力を得て、空白を3つのドットに変更し、出力を印刷する必要がある。

  • So how can we do the first test?

    では、最初のテストはどうすればいいのか?

  • How can we get input from the user?

    どうすればユーザーから意見を得られるか?

  • Let's see this explanation.

    この説明を見てみよう。

  • Basically the function input allows us to ask questions to the user and the answer that the user typed in, we can start in a variable.

    基本的にinput関数は、ユーザーに質問し、ユーザーが入力した答えを変数に入れることができる。

  • For example, if we want to ask the name of the user, we can do username equals to input.

    例えば、ユーザーの名前を尋ねたい場合、ユーザー名イコール入力とすることができる。

  • What's your name?

    お名前は?

  • And it will be prompt in the terminal.

    そしてターミナルにプロンプトが表示される。

  • The user can write his name.

    ユーザーは自分の名前を書くことができる。

  • If the user types in Giovanna, the variable username will start Giovanna.

    ユーザーがGiovannaと入力すると、変数usernameはGiovannaを開始する。

  • Since the answer is stored in a variable, we can use this answer in our code.

    答えは変数に格納されているので、この答えをコードで使うことができる。

  • So like we saw, we can use the input function, alright?

    だから、さっき見たように、入力関数を使えばいいんだ。

  • So let's grab the message from the user.

    では、ユーザーからのメッセージを受け取ってみよう。

  • So I'm going to create here a variable called msg to start a message and we're going to use input here, okay?

    ここでmsgという変数を作ってメッセージを開始し、ここでinputを使うんだ。

  • If you want, you can type something in here inside the input, but in our case, I won't type anything, alright?

    必要であれば、ここに何か入力することもできるが、今回の場合は何も入力しない、いいね?

  • So we're going to see here that if we do python playback.py, it's going to appear this cursor where we can type in this is CS50 and this message is stored in our code, okay?

    pythonのplayback.pyを実行すると、CS50と入力できるカーソルが表示される。

  • If we print the output, it will print the same message.

    出力をプリントしても、同じメッセージがプリントされる。

  • If we do print a message, it will print this, this is CS50, okay?

    メッセージを印刷する場合は、CS50と表示される。

  • It's printing the same thing.

    同じものを印刷しているんだ。

  • But this is not the goal of our problem.

    しかし、これは私たちの問題のゴールではない。

  • The goal of our problem is to change the whitespace for three periods.

    この問題の目標は、3つのピリオドの空白を変更することである。

  • So how can we do this?

    では、どうすればいいのか?

  • We're going to use the replace function.

    replace関数を使うことにする。

  • Let's understand how this replace function works.

    この置換機能がどのように働くかを理解しよう。

  • The replace method replaces a specified phrase with another specified phrase.

    replace メソッドは、指定したフレーズを別の指定したフレーズに置き換える。

  • If we will have a variable txt equals to I like bananas and we want to change bananas to apple, we can use the replace method to make this change for us.

    もしtxtという変数がI like bananasに等しく、bananasをappleに変更したい場合、replaceメソッドを使って変更することができる。

  • We can do txt.replace and inside the parenthesis we put the word that we want to change, in our case bananas, with the new word that we want to replace, in our case apples, and our string txt will become I like apples.

    txt.replaceを実行し、括弧の中に変更したい単語(この場合はbananas)を新しい単語(この場合はapples)で置き換えると、文字列txtはI like applesになる。

  • So in our case, instead of replacing bananas to apples, we're going to replace whitespace for three dots, okay?

    バナナをリンゴに置き換える代わりに、空白を3つのドットに置き換えるんだ。

  • So let's create a new variable I'm going to call new message, alright?

    では、new messageと呼ぶ新しい変数を作ってみよう。

  • And in here we're going to use the previous variable that was storing the message, so msg. and now we're going to use the method replace, okay?

    そしてここでは、メッセージを格納していた以前の変数、msg.を使用し、メソッドのreplaceを使用します。

  • So .replace and what we want to replace?

    では、何を置き換えるのか?

  • We have to pass two arguments, two parameters.

    つの引数、2つのパラメーターを渡さなければならない。

  • The first one will be the word or the character that we want to replace.

    最初の文字は、置き換えたい単語や文字になる。

  • So in our case we want to replace whitespace.

    つまり、この場合は空白を置き換えたいのだ。

  • So in here we're going to use quotation mark and click space in the middle, alright?

    だから、ここでは引用符を使って、真ん中のスペースをクリックするんだ。

  • So we can signalize that we want to replace the whitespace.

    つまり、空白を置き換えたいことを示すことができる。

  • And we want to replace by what?

    そして、何に置き換えたいのか?

  • So in here we're going to use three dots inside.

    だからここでは、中に3つの点を使うんだ。

  • So this means that everything that is whitespace will become three dots, okay?

    つまり、空白はすべて3つのドットになるということだ。

  • And finally we're going to print this new variable that we are storing the new message, okay?

    そして最後に、新しいメッセージを格納する新しい変数を表示するんだ。

  • So let's try it out.

    では、試してみよう。

  • So if we do python playback.py and if we type in this is cs50.

    だからpythonのplayback.pyにcs50と入力する。

  • Now we have the three periods instead of the whitespaces, okay?

    空白の代わりにピリオドを3つ入れよう。

  • So this is it for the function.

    というわけで、ファンクションはここまで。

  • Let's do check50 and see if it's working.

    チェック50をして、機能しているかどうか見てみよう。

  • So if we take a look in here, we took all green.

    だから、ここを見てみよう。

  • So this means that our code is running fine, okay?

    つまり、このコードは問題なく実行されているということだ。

  • So this is it for the playback problem.

    再生問題については以上だ。

  • If you have any questions, please let us know, send us a message or a comment, subscribe to our channel, please give us a thumbs up and see you in the next video, alright?

    何か質問があれば、メッセージやコメント、チャンネル登録、サムズアップをお願いします。

  • Bye bye!

    バイバイ!

Hi everyone, my name is Giovanna Proença and today we're going to talk about Problem

皆さん、こんにちは。私の名前はジョバンナ・プロエンサです。

字幕と単語
AI 自動生成字幕

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

A2 初級 日本語

問題セット0:再生速度|解答(cs50 python) (PROBLEM SET 0: PLAYBACK SPEED | SOLUTION (CS50 PYTHON))

  • 5 0
    林照翌 に公開 2024 年 09 月 30 日
動画の中の単語