Skip to content
TheChatArchiveThe Chat Archive
o1-mini-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

please translate any text, phrases, word, ... to persian and not summarized and noting…

  1. User

    please translate any text, phrases, word, ... to persian and not summarized and noting any other and any message: "WEBVTT

    1 00:00:00.000 --> 00:00:03.400 In this video, you will learn about conditions and branching.

    2 00:00:03.400 --> 00:00:07.150 Comparison operations compares some value or operand.

    3 00:00:07.150 --> 00:00:09.330 Then based on some condition,

    4 00:00:09.330 --> 00:00:10.830 they produce a Boolean.

    5 00:00:10.830 --> 00:00:14.830 Let's say we assign a value of a to six.

    6 00:00:14.830 --> 00:00:17.420 We can use the equality operator denoted with

    7 00:00:17.420 --> 00:00:21.370 two equal signs to determine if two values are equal.

    8 00:00:21.370 --> 00:00:24.660 In this case, if seven is equal to six.

    9 00:00:24.660 --> 00:00:27.680 In this case, as six is not equal to seven,

    10 00:00:27.680 --> 00:00:29.480 the result is false.

    11 00:00:29.480 --> 00:00:32.890 If we performed an equality test for the value six,

    12 00:00:32.890 --> 00:00:34.920 the two values would be equal.

    13 00:00:34.920 --> 00:00:37.110 As a result, we would get a true.

    14 00:00:37.110 --> 00:00:40.480 Consider the following equality comparison operator:

    15 00:00:40.480 --> 00:00:43.490 If the value of the left operand, in this case,

    16 00:00:43.490 --> 00:00:47.540 the variable i is greater than the value of the right operand,

    17 00:00:47.540 --> 00:00:49.150 in this case five,

    18 00:00:49.150 --> 00:00:52.890 the condition becomes true or else we get a false.

    19 00:00:52.890 --> 00:00:55.770 Let's display some values for i on the left.

    20 00:00:55.770 --> 00:01:00.340 Let's see the value is greater than five in green and the rest in red.

    21 00:01:00.340 --> 00:01:02.810 If we set i equal to six,

    22 00:01:02.810 --> 00:01:07.520 we see that six is larger than five and as a result, we get a true.

    23 00:01:07.520 --> 00:01:10.860 We can also apply the same operations to floats.

    24 00:01:10.860 --> 00:01:13.620 If we modify the operator as follows,

    25 00:01:13.620 --> 00:01:19.210 if the left operand i is greater than or equal to the value of the right operand,

    26 00:01:19.210 --> 00:01:20.720 in this case five,

    27 00:01:20.720 --> 00:01:22.780 then the condition becomes true.

    28 00:01:22.780 --> 00:01:24.960 In this case, we include the value of

    29 00:01:24.960 --> 00:01:28.960 five in the number line and the color changes to green accordingly.

    30 00:01:28.960 --> 00:01:31.900 If we set the value of i equal to five,

    31 00:01:31.900 --> 00:01:34.180 the operand will produce a true.

    32 00:01:34.180 --> 00:01:36.750 If we set the value of i to two,

    33 00:01:36.750 --> 00:01:39.900 we would get a false because two is less than five.

    34 00:01:39.900 --> 00:01:44.470 We can change the inequality if the value of the left operand, in this case,

    35 00:01:44.470 --> 00:01:47.590 i is less than the value of the right operand,

    36 00:01:47.590 --> 00:01:49.480 in this case, six.

    37 00:01:49.480 --> 00:01:51.500 Then condition becomes true.

    38 00:01:51.500 --> 00:01:54.870 Again, we can represent this with a colored number line.

    39 00:01:54.870 --> 00:01:57.910 The areas where the inequality is true are marked in

    40 00:01:57.910 --> 00:02:01.250 green and red where the inequality is false.

    41 00:02:01.250 --> 00:02:03.810 If the value for i is set to two,

    42 00:02:03.810 --> 00:02:05.390 the result is a true.

    43 00:02:05.390 --> 00:02:07.770 As two is less than six.

    44 00:02:07.770 --> 00:02:12.630 The inequality test uses an explanation mark preceding the equal sign.

    45 00:02:12.630 --> 00:02:15.030 If two operands are not equal,

    46 00:02:15.030 --> 00:02:17.140 then the condition becomes true.

    47 00:02:17.140 --> 00:02:18.940 We can use a number line.

    48 00:02:18.940 --> 00:02:20.850 When the condition is true,

    49 00:02:20.850 --> 00:02:26.390 the corresponding numbers are marked in green and red for where the condition is false.

    50 00:02:26.390 --> 00:02:28.840 If we set i equal to two,

    51 00:02:28.840 --> 00:02:32.900 the operator is true as two is not equal to six.

    52 00:02:32.900 --> 00:02:34.960 We compare strings as well.

    53 00:02:34.960 --> 00:02:40.170 Comparing ACDC and Michael Jackson using the equality test,

    54 00:02:40.170 --> 00:02:43.460 we get a false, as the strings are not the same.

    55 00:02:43.460 --> 00:02:45.520 Using the inequality test,

    56 00:02:45.520 --> 00:02:48.440 we get a true, as the strings are different.

    57 00:02:48.440 --> 00:02:50.880 See the Lapps for more examples.

    58 00:02:50.880 --> 00:02:55.010 Branching allows us to run different statements for a different input.

    59 00:02:55.010 --> 00:02:58.920 It's helpful to think of an if statement as a locked room.

    60 00:02:58.920 --> 00:03:00.670 If this statement is true,

    61 00:03:00.670 --> 00:03:05.360 you can enter the room and your program can run some predefined task.

    62 00:03:05.360 --> 00:03:07.070 If the statement is false,

    63 00:03:07.070 --> 00:03:09.230 your program will skip the task.

    64 00:03:09.230 --> 00:03:15.200 For example, consider the blue rectangle representing an ACDC concert.

    65 00:03:15.200 --> 00:03:17.780 If the individual is 18 or older,

    66 00:03:17.780 --> 00:03:20.240 they can enter the ACDC concert.

    67 00:03:20.240 --> 00:03:22.230 If they are under the age of 18,

    68 00:03:22.230 --> 00:03:24.040 they cannot enter the concert.

    69 00:03:24.040 --> 00:03:28.100 Individual proceeds to the concert their age is 17,

    70 00:03:28.100 --> 00:03:33.300 therefore, they are not granted access to the concert and they must move on.

    71 00:03:33.300 --> 00:03:35.420 If the individual is 19,

    72 00:03:35.420 --> 00:03:36.790 the condition is true.

    73 00:03:36.790 --> 00:03:39.970 They can enter the concert then they can move on.

    74 00:03:39.970 --> 00:03:44.070 This is the syntax of the if statement from our previous example.

    75 00:03:44.070 --> 00:03:45.930 We have the if statement.

    76 00:03:45.930 --> 00:03:49.080 We have the expression that can be true or false.

    77 00:03:49.080 --> 00:03:52.750 The brackets are not necessary. We have a colon.

    78 00:03:52.750 --> 00:03:57.480 Within an indent, we have the expression that is run if the condition is true.

    79 00:03:57.480 --> 00:04:00.190 The statements after the if statement will run

    80 00:04:00.190 --> 00:04:03.100 regardless if the condition is true or false.

    81 00:04:03.100 --> 00:04:05.440 For the case where the age is 17,

    82 00:04:05.440 --> 00:04:08.750 we set the value of the variable age to 17.

    83 00:04:08.750 --> 00:04:10.570 We check the if statement,

    84 00:04:10.570 --> 00:04:12.270 the statement is false.

    85 00:04:12.270 --> 00:04:17.140 Therefore the program will not execute the statement to print, "you will enter".

    86 00:04:17.140 --> 00:04:20.420 In this case, it will just print "move on".

    87 00:04:20.420 --> 00:04:22.530 For the case where the age is 19,

    88 00:04:22.530 --> 00:04:25.480 we set the value of the variable age to 19.

    89 00:04:25.480 --> 00:04:27.290 We check the if statement.

    90 00:04:27.290 --> 00:04:28.810 The statement is true.

    91 00:04:28.810 --> 00:04:33.060 Therefore, the program will execute the statement to print "you will enter".

    92 00:04:33.060 --> 00:04:35.660 Then it will just print "move on".

    93 00:04:35.660 --> 00:04:40.830 The else statement will run a different block of code if the same condition is false.

    94 00:04:40.830 --> 00:04:44.320 Let's use the ACDC concert analogy again.

    95 00:04:44.320 --> 00:04:46.060 If the user is 17,

    96 00:04:46.060 --> 00:04:48.930 they cannot go to the ACDC concert but they

    97 00:04:48.930 --> 00:04:52.670 can go to the Meat Loaf concert represented by the purple square.

    98 00:04:52.670 --> 00:04:54.710 If the individual is 19,

    99 00:04:54.710 --> 00:04:55.980 the condition is true,

    100 00:04:55.980 --> 00:05:00.640 they can enter the ACDC concert then they can move on as before. "

  2. Assistant
    WEBVTT
    
    1
    00:00:00.000 --> 00:00:03.400
    در این ویدیو، شما درباره شرایط و شاخه‌بندی یاد خواهید گرفت.
    
    2
    00:00:03.400 --> 00:00:07.150
    عملیات مقایسه برخی مقادیر یا عملوندها را مقایسه می‌کند.
    
    3
    00:00:07.150 --> 00:00:09.330
    سپس بر اساس برخی شرایط،
    
    4
    00:00:09.330 --> 00:00:10.830
    یک بولین تولید می‌کنند.
    
    5
    00:00:10.830 --> 00:00:14.830
    بیایید فرض کنیم که مقدار a را به شش اختصاص می‌دهیم.
    
    6
    00:00:14.830 --> 00:00:17.420
    ما می‌توانیم از عملگر برابری که با
    
    7
    00:00:17.420 --> 00:00:21.370
    دو علامت مساوی نشان داده شده است، برای تعیین اینکه آیا دو مقدار برابر هستند استفاده کنیم.
    
    8
    00:00:21.370 --> 00:00:24.660
    در این حالت، اگر هفت با شش برابر باشد.
    
    9
    00:00:24.660 --> 00:00:27.680
    در این حالت، چون شش با هفت برابر نیست،
    
    10
    00:00:27.680 --> 00:00:29.480
    نتیجه نادرست (false) است.
    
    11
    00:00:29.480 --> 00:00:32.890
    اگر یک آزمون برابر بودن برای مقدار شش انجام دهیم،
    
    12
    00:00:32.890 --> 00:00:34.920
    دو مقدار برابر خواهند بود.
    
    13
    00:00:34.920 --> 00:00:37.110
    در نتیجه، مقدار درست (true) دریافت می‌کنیم.
    
    14
    00:00:37.110 --> 00:00:40.480
    عملگر مقایسه برابری زیر را در نظر بگیرید:
    
    15
    00:00:40.480 --> 00:00:43.490
    اگر مقدار عملوند سمت چپ، در این مورد،
    
    16
    00:00:43.490 --> 00:00:47.540
    متغیر i بیشتر از مقدار عملوند سمت راست باشد،
    
    17
    00:00:47.540 --> 00:00:49.150
    در این حالت پنج،
    
    18
    00:00:49.150 --> 00:00:52.890
    شرط درست می‌شود وگرنه نادرست دریافت می‌کنیم.
    
    19
    00:00:52.890 --> 00:00:55.770
    بیایید برخی مقادیر برای i را در سمت چپ نمایش دهیم.
    
    20
    00:00:55.770 --> 00:01:00.340
    ببینیم که آیا مقدار بیش‌تر از پنج است در رنگ سبز و بقیه در قرمز.
    
    21
    00:01:00.340 --> 00:01:02.810
    اگر ما i را به شش برابر کنیم،
    
    22
    00:01:02.810 --> 00:01:07.520
    می‌بینیم که شش بزرگ‌تر از پنج است و در نتیجه، مقدار درست دریافت می‌کنیم.
    
    23
    00:01:07.520 --> 00:01:10.860
    ما همچنین می‌توانیم همین عملیات را روی اعداد اعشاری (float) اعمال کنیم.
    
    24
    00:01:10.860 --> 00:01:13.620
    اگر عملگر را به صورت زیر تغییر دهیم،
    
    25
    00:01:13.620 --> 00:01:19.210
    اگر عملوند سمت چپ i بیشتر یا برابر با مقدار عملوند سمت راست باشد،
    
    26
    00:01:19.210 --> 00:01:20.720
    در این حالت پنج،
    
    27
    00:01:20.720 --> 00:01:22.780
    سپس شرط درست می‌شود.
    
    28
    00:01:22.780 --> 00:01:24.960
    در این حالت، ما مقدار
    
    29
    00:01:24.960 --> 00:01:28.960
    پنج را در خط اعداد شامل می‌کنیم و رنگ به طور متناسب به سبز تغییر می‌کند.
    
    30
    00:01:28.960 --> 00:01:31.900
    اگر مقدار i را به پنج برابر کنیم،
    
    31
    00:01:31.900 --> 00:01:34.180
    عملوند مقدار درست را تولید می‌کند.
    
    32
    00:01:34.180 --> 00:01:36.750
    اگر مقدار i را به دو برابر کنیم،
    
    33
    00:01:36.750 --> 00:01:39.900
    نتیجه نادرست دریافت خواهیم کرد زیرا دو کمتر از پنج است.
    
    34
    00:01:39.900 --> 00:01:44.470
    می‌توانیم نابرابری را تغییر دهیم اگر مقدار عملوند سمت چپ، در این مورد،
    
    35
    00:01:44.470 --> 00:01:47.590
    i کمتر از مقدار عملوند سمت راست باشد،
    
    36
    00:01:47.590 --> 00:01:49.480
    در این حالت شش.
    
    37
    00:01:49.480 --> 00:01:51.500
    سپس شرط درست می‌شود.
    
    38
    00:01:51.500 --> 00:01:54.870
    باز هم، ما می‌توانیم این را با یک خط اعداد رنگی نمایش دهیم.
    
    39
    00:01:54.870 --> 00:01:57.910
    مناطق که نابرابری درست است در
    
    40
    00:01:57.910 --> 00:02:01.250
    سبز نشان‌گذاری شده‌اند و قرمز جایی که نابرابری نادرست است.
    
    41
    00:02:01.250 --> 00:02:03.810
    اگر مقدار i به دو برابر شود،
    
    42
    00:02:03.810 --> 00:02:05.390
    نتیجه درست است.
    
    43
    00:02:05.390 --> 00:02:07.770
    زیرا دو کمتر از شش است.
    
    44
    00:02:07.770 --> 00:02:12.630
    آزمون نابرابری از علامت تعجب قبلی نسبت به علامت مساوی استفاده می‌کند.
    
    45
    00:02:12.630 --> 00:02:15.030
    اگر دو عملوند برابر نباشند،
    
    46
    00:02:15.030 --> 00:02:17.140
    آنگاه شرط درست می‌شود.
    
    47
    00:02:17.140 --> 00:02:18.940
    ما می‌توانیم از یک خط اعداد استفاده کنیم.
    
    48
    00:02:18.940 --> 00:02:20.850
    وقتی که شرط درست است،
    
    49
    00:02:20.850 --> 00:02:26.390
    اعداد مربوطه در سبز نشان‌گذاری شده‌اند و قرمز برای جایی که شرط نادرست است.
    
    50
    00:02:26.390 --> 00:02:28.840
    اگر i را به دو برابر کنیم،
    
    51
    00:02:28.840 --> 00:02:32.900
    عملگر درست است زیرا دو با شش برابر نیست.
    
    52
    00:02:32.900 --> 00:02:34.960
    ما همچنین رشته‌ها را مقایسه می‌کنیم.
    
    53
    00:02:34.960 --> 00:02:40.170
    مقایسه ACDC و Michael Jackson با استفاده از آزمون برابر بودن،
    
    54
    00:02:40.170 --> 00:02:43.460
    ما نتیجه نادرست دریافت می‌کنیم، زیرا رشته‌ها یکسان نیستند.
    
    55
    00:02:43.460 --> 00:02:45.520
    با استفاده از آزمون نابرابری،
    
    56
    00:02:45.520 --> 00:02:48.440
    ما نتیجه درست دریافت می‌کنیم، زیرا رشته‌ها متفاوت هستند.
    
    57
    00:02:48.440 --> 00:02:50.880
    برای مثال‌های بیشتر، به Lapps مراجعه کنید.
    
    58
    00:02:50.880 --> 00:02:55.010
    شاخه‌بندی به ما اجازه می‌دهد که دستورات مختلفی برای ورودی‌های مختلف اجرا کنیم.
    
    59
    00:02:55.010 --> 00:02:58.920
    مفید است که دستور if را به عنوان یک اتاق قفل‌شده در نظر بگیریم.
    
    60
    00:02:58.920 --> 00:03:00.670
    اگر این شرط درست باشد،
    
    61
    00:03:00.670 --> 00:03:05.360
    می‌توانید وارد اتاق شوید و برنامه‌تان می‌تواند برخی کارهای از پیش تعریف‌شده را اجرا کند.
    
    62
    00:03:05.360 --> 00:03:07.070
    اگر شرط نادرست باشد،
    
    63
    00:03:07.070 --> 00:03:09.230
    برنامه شما وظیفه را نادیده خواهد گرفت.
    
    64
    00:03:09.230 --> 00:03:15.200
    برای مثال، مستطیل آبی نمایش‌دهنده کنسرت ACDC را در نظر بگیرید.
    
    65
    00:03:15.200 --> 00:03:17.780
    اگر فرد ۱۸ سال یا بیشتر باشد،
    
    66
    00:03:17.780 --> 00:03:20.240
    می‌توانند وارد کنسرت ACDC شوند.
    
    67
    00:03:20.240 --> 00:03:22.230
    اگر زیر ۱۸ سال باشند،
    
    68
    00:03:22.230 --> 00:03:24.040
    نمی‌توانند وارد کنسرت شوند.
    
    69
    00:03:24.040 --> 00:03:28.100
    فرد به سمت کنسرت می‌رود و سن او ۱۷ سال است،
    
    70
    00:03:28.100 --> 00:03:33.300
    بنابراین، به او اجازه ورود به کنسرت داده نمی‌شود و باید ادامه دهد.
    
    71
    00:03:33.300 --> 00:03:35.420
    اگر فرد ۱۹ سال باشد،
    
    72
    00:03:35.420 --> 00:03:36.790
    شرط درست است.
    
    73
    00:03:36.790 --> 00:03:39.970
    می‌توانند وارد کنسرت شوند سپس می‌توانند همانطور که قبل است ادامه دهند.
    
    74
    00:03:39.970 --> 00:03:44.070
    این سینتکس دستور if از مثال قبلی ما است.
    
    75
    00:03:44.070 --> 00:03:45.930
    ما دستور if را داریم.
    
    76
    00:03:45.930 --> 00:03:49.080
    ما عبارت داریم که می‌تواند درست یا نادرست باشد.
    
    77
    00:03:49.080 --> 00:03:52.750
    براکت‌ها ضروری نیستند. ما یک دو نقطه داریم.
    
    78
    00:03:52.750 --> 00:03:57.480
    درون تورفتگی، عبارت که اگر شرط درست باشد اجرا می‌شود را داریم.
    
    79
    00:03:57.480 --> 00:04:00.190
    دستورات بعد از دستور if اجرا خواهند شد
    
    80
    00:04:00.190 --> 00:04:03.100
    صرف نظر از اینکه شرط درست یا نادرست باشد.
    
    81
    00:04:03.100 --> 00:04:05.440
    برای حالتی که سن ۱۷ است،
    
    82
    00:04:05.440 --> 00:04:08.750
    ما مقدار متغیر age را به ۱۷ تنظیم می‌کنیم.
    
    83
    00:04:08.750 --> 00:04:10.570
    دستور if را بررسی می‌کنیم،
    
    84
    00:04:10.570 --> 00:04:12.270
    دستور نادرست است.
    
    85
    00:04:12.270 --> 00:04:17.140
    بنابراین برنامه دستور چاپ، "شما وارد خواهید شد" را اجرا نخواهد کرد.
    
    86
    00:04:17.140 --> 00:04:20.420
    در این حالت، فقط "ادامه دهید" چاپ خواهد شد.
    
    87
    00:04:20.420 --> 00:04:22.530
    برای حالتی که سن ۱۹ است،
    
    88
    00:04:22.530 --> 00:04:25.480
    ما مقدار متغیر age را به ۱۹ تنظیم می‌کنیم.
    
    89
    00:04:25.480 --> 00:04:27.290
    دستور if را بررسی می‌کنیم.
    
    90
    00:04:27.290 --> 00:04:28.810
    دستور درست است.
    
    91
    00:04:28.810 --> 00:04:33.060
    بنابراین، برنامه دستور چاپ "شما وارد خواهید شد" را اجرا خواهد کرد.
    
    92
    00:04:33.060 --> 00:04:35.660
    سپس فقط "ادامه دهید" چاپ خواهد شد.
    
    93
    00:04:35.660 --> 00:04:40.830
    دستور else یک بلوک کد متفاوت اجرا می‌کند اگر همان شرط نادرست باشد.
    
    94
    00:04:40.830 --> 00:04:44.320
    بیایید دوباره از تشبیه کنسرت ACDC استفاده کنیم.
    
    95
    00:04:44.320 --> 00:04:46.060
    اگر کاربر ۱۷ سال باشد،
    
    96
    00:04:46.060 --> 00:04:48.930
    نمی‌تواند به کنسرت ACDC برود اما می‌تواند
    
    97
    00:04:48.930 --> 00:04:52.670
    به کنسرت Meat Loaf که با مربع بنفش نمایش داده شده است بروید.
    
    98
    00:04:52.670 --> 00:04:54.710
    اگر فرد ۱۹ سال باشد،
    
    99
    00:04:54.710 --> 00:04:55.980
    شرط درست است،
    
    100
    00:04:55.980 --> 00:05:00.640
    می‌توانند وارد کنسرت ACDC شوند سپس همانطور که قبلا، ادامه دهند.