Difference between revisions of "Ruby/C2/Control-Statements/Kannada"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 112: Line 112:
 
|-
 
|-
 
|  02:12
 
|  02:12
| Let's look at the ''' 'if-else' statement''' next.  
+
| ನಂತರ, ನಾವು 'if-else' ಸ್ಟೇಟ್ಮೆಂಟ್ ಅನ್ನು ನೋಡೋಣ.  
 
|-
 
|-
 
|  02:16
 
|  02:16
| The syntax for using '''else''' is:  
+
| 'else'ಅನ್ನು ಬಳಸಲು ಸಿಂಟ್ಯಾಕ್ಸ್ ಹೀಗಿದೆ:  
 
|-
 
|-
 
| 02:18
 
| 02:18
|''' if “condition” '''
+
| 'if' ಕಂಡೀಶನ್
 
|-
 
|-
 
|  02:19
 
|  02:19
| ''' ruby code'''  
+
| 'ರೂಬಿ ಕೋಡ್'  
 
|-
 
|-
 
| 02:20
 
| 02:20
|'''else'''
+
| 'else'
 
|-
 
|-
 
|  02:21
 
|  02:21
| '''ruby code '''
+
| 'ರೂಬಿ ಕೋಡ್'
 
|-
 
|-
 
| 02:22
 
| 02:22
| ''' end'''
+
| 'end'
 
|-
 
|-
 
| 02:24
 
| 02:24
| Let us look at an example.  
+
| ನಾವು ಒಂದು ಉದಾಹರಣೆಯನ್ನು ನೋಡೋಣ.
 
|-
 
|-
 
| 02:26
 
| 02:26
|Create a new file in ''' gedit''' as shown in the basic level ''' Ruby tutorials'''.
+
| ಪ್ರಾಥಮಿಕ ಹಂತದ''' Ruby tutorials'''ನಲ್ಲಿ ತೋರಿಸಿದಂತೆ, 'gedit'ನಲ್ಲಿ  ಒಂದು ಹೊಸ ಫೈಲನ್ನು ಕ್ರಿಯೇಟ್ ಮಾಡಿ.  
 
|-
 
|-
 
| 02:30
 
| 02:30
|Name it '''if hyphen else hyphen statement dot rb'''.
+
| ಅದನ್ನು 'if hyphen else hyphen statement dot rb' ಎಂದು ಹೆಸರಿಸಿ.
 
|-
 
|-
 
| 02:37
 
| 02:37
|I have a working example of the ''' 'if-else' statement.'''  
+
| ನನ್ನ ಹತ್ತಿರ ಒಂದು ಉದಾಹರಣೆಯಿದೆ.I have a working example of the ''' 'if-else' statement.'''  
 
|-
 
|-
 
|  02:40
 
|  02:40

Revision as of 13:10, 22 December 2015

Time Narration
00:01 'Ruby' ಯಲ್ಲಿ, 'Control Statements' ಎಂಬ 'Spoken Tutorial' ಗೆ ನಿಮಗೆ ಸ್ವಾಗತ.
00:06 ಈ ಟ್ಯುಟೋರಿಯಲ್ ನಲ್ಲಿ ನಾವು:
00:08 * 'if' ಸ್ಟೇಟ್ಮೆಂಟ್
00:09 * 'elsif' ಸ್ಟೇಟ್ಮೆಂಟ್
00:11 * 'else'
00:12 * 'case' ಸ್ಟೇಟ್ಮೆಂಟ್ ಗಳನ್ನು ಬಳಸಲು ಕಲಿಯುವೆವು.
00:14 ಇಲ್ಲಿ ನಾವು:
00:15 * Ubuntu ಆವೃತ್ತಿ 12.04
00:18 * Ruby 1.9.3 ಇವುಗಳನ್ನು ಬಳಸುತ್ತಿದ್ದೇವೆ.
00:21 ಈ ಟ್ಯುಟೋರಿಯಲ್ ಅನ್ನು ಅನುಸರಿಸಲು, ನೀವು 'ಇಂಟರ್ನೆಟ್'ನ ಸಂಪರ್ಕವನ್ನು ಪಡೆದಿರಬೇಕು.
00:24 'Linux' ಕಮಾಂಡ್ ಗಳು, ‘ಟರ್ಮಿನಲ್’ ಮತ್ತು 'ಟೆಕ್ಸ್ಟ್ ಎಡಿಟರ್' ಗಳನ್ನು ನೀವು ತಿಳಿದಿರಬೇಕು.
00:30 ಇಲ್ಲದಿದ್ದರೆ, ಸಂಬಂಧಿತ ಟ್ಯುಟೋರಿಯಲ್ ಗಳಿಗಾಗಿ, ದಯವಿಟ್ಟು ನಮ್ಮ ವೆಬ್ಸೈಟ್ ಗೆ ಭೆಟ್ಟಿಕೊಡಿ.
00:34 ನಾವು ಆರಂಭಿಸುವ ಮುನ್ನ, ಈಮೊದಲು ನಾವು “ttt” ಎಂಬ ಡಿರೆಕ್ಟರೀಯನ್ನು ಕ್ರಿಯೇಟ್ ಮಾಡಿದ್ದೆವು ಎಂಬುದನ್ನು ನೆನಪಿಸಿಕೊಳ್ಳಿ.
00:38 ನಾವು ಆ ಡಿರೆಕ್ಟರೀಗೆ ಹೋಗೋಣ.
00:41 ಆಮೇಲೆ, 'ruby hyphen tutorial' 'control hyphen statements' ಗೆ ಹೋಗೋಣ.
00:47 ಈಗ ನಾವು ಅದೇ ಫೋಲ್ಡರ್ ನಲ್ಲಿ ಇರುವುದರಿಂದ ಮುಂದೆ ನಡೆಯೋಣ.
00:52 Ruby ಯಲ್ಲಿ, 'if' ಸ್ಟೇಟ್ಮೆಂಟ್ ನ ಸಿಂಟ್ಯಾಕ್ಸ್ ಈಕೆಳಗಿನಂತಿದೆ:
00:56 'if ಕಂಡೀಶನ್ '
00:58 'ರೂಬಿ ಕೋಡ್'
00:59 'end'
01:01 ನಾವು ಒಂದು ಉದಾಹರಣೆಯನ್ನು ನೋಡೋಣ.
01:03 ಪ್ರಾಥಮಿಕ ಹಂತದ Ruby tutorials ನಲ್ಲಿ ತೋರಿಸಿದಂತೆ, 'gedit' ನಲ್ಲಿ ಒಂದು ಹೊಸ ಫೈಲನ್ನು ಕ್ರಿಯೇಟ್ ಮಾಡಿ.
01:08 ಇದನ್ನು "if hyphen statement dot rb" ಎಂದು ಹೆಸರಿಸಿ.
01:12 ನನ್ನ ಹತ್ತಿರ 'if ಸ್ಟೇಟ್ಮೆಂಟ್'ನ ಒಂದು ಉದಾಹರಣೆ ಇದೆ.
01:15 ನಾವು ಮುಂದುವರಿಯುತ್ತಿದ್ದಂತೆ, ನೀವು ಟ್ಯುಟೋರಿಯಲ್ ಅನ್ನು ನಿಲ್ಲಿಸಿ ಕೋಡ್ ಅನ್ನು ಟೈಪ್ ಮಾಡಬಹುದು.
01:19 ಈ ಉದಾಹರಣೆಯಲ್ಲಿ, ನಾನು ಒಂದು 'if ಸ್ಟೇಟ್ಮೆಂಟ್'ಅನ್ನು ಡಿಕ್ಲೇರ್ ಮಾಡಿದ್ದೇನೆ.
01:23 ಮೊದಲು, ನಾನು 'my_num' ಎಂಬ ಒಂದು ಲೋಕಲ್ ವೇರಿಯೆಬಲ್ ಅನ್ನು ಡಿಕ್ಲೇರ್ ಮಾಡಿ, ಅದಕ್ಕೆ 2345 ವ್ಯಾಲ್ಯೂಅನ್ನು ಅಸೈನ್ ಮಾಡುತ್ತೇನೆ.
01:31 ಆಮೇಲೆ ಒಂದು 'if ಸ್ಟೇಟ್ಮೆಂಟ್'ಅನ್ನು ಡಿಕ್ಲೇರ್ ಮಾಡುತ್ತೇನೆ.
01:34 'if ಸ್ಟೇಟ್ಮೆಂಟ್'ನ ಒಳಗಡೆ ಡಿಕ್ಲೇರ್ ಮಾಡಲಾದ 'puts' ಮೆಥಡ್, ಔಟ್ಪುಟ್ ಅನ್ನು ತೋರಿಸುವುದು.
01:39 'if ಸ್ಟೇಟ್ಮೆಂಟ್', 'my_num'ನ ವ್ಯಾಲ್ಯೂ, 0 (ಸೊನ್ನೆ)ಗಿಂತ ಹೆಚ್ಚಾಗಿದೆಯೋ ಎಂಬುದನ್ನು ಪರೀಕ್ಷಿಸುವುದು.
01:43 ಒಂದುವೇಳೆ ಹೌದು ಎಂದಾದರೆ, ಇದು ನಿಗದಿತ ಸ್ಟ್ರಿಂಗ್ ಅನ್ನು ಪ್ರಿಂಟ್ ಮಾಡುವುದು.
01:47 ಈಗ, ನಾವು ಟರ್ಮಿನಲ್ ಗೆ ಬದಲಾಯಿಸೋಣ ಮತ್ತು ಹೀಗೆ ಟೈಪ್ ಮಾಡೋಣ.
01:51 "ruby space if hyphen statement dot rb".
01:57 ಔಟ್ಪುಟ್, “The value of my_num is greater than 0” ಎಂದು ತೋರಿಸುವುದು.
02:02 ಈ ಔಟ್ಪುಟ್, 'if ಕಂಡೀಶನ್' 'true' ಅನ್ನು ಹಿಂದಿರುಗಿಸಿದೆ ಎಂಬುದನ್ನು ಧೃಢಪಡಿಸುತ್ತದೆ.
02:07 ಈಗ, ನಿಮಗೆ 'ರೂಬಿ'ಯಲ್ಲಿ ನಿಮ್ಮ ಸ್ವಂತದ 'if ಸ್ಟೇಟ್ಮೆಂಟ್'ಅನ್ನು ಬರೆಯಲು ಸಾಧ್ಯವಾಗಬೇಕು.
02:12 ನಂತರ, ನಾವು 'if-else' ಸ್ಟೇಟ್ಮೆಂಟ್ ಅನ್ನು ನೋಡೋಣ.
02:16 'else'ಅನ್ನು ಬಳಸಲು ಸಿಂಟ್ಯಾಕ್ಸ್ ಹೀಗಿದೆ:
02:18 'if' ಕಂಡೀಶನ್
02:19 'ರೂಬಿ ಕೋಡ್'
02:20 'else'
02:21 'ರೂಬಿ ಕೋಡ್'
02:22 'end'
02:24 ನಾವು ಒಂದು ಉದಾಹರಣೆಯನ್ನು ನೋಡೋಣ.
02:26 ಪ್ರಾಥಮಿಕ ಹಂತದ Ruby tutorialsನಲ್ಲಿ ತೋರಿಸಿದಂತೆ, 'gedit'ನಲ್ಲಿ ಒಂದು ಹೊಸ ಫೈಲನ್ನು ಕ್ರಿಯೇಟ್ ಮಾಡಿ.
02:30 ಅದನ್ನು 'if hyphen else hyphen statement dot rb' ಎಂದು ಹೆಸರಿಸಿ.
02:37 ನನ್ನ ಹತ್ತಿರ ಒಂದು ಉದಾಹರಣೆಯಿದೆ.I have a working example of the 'if-else' statement.
02:40 You can pause the tutorial and type the code as we go through it.
02:44 I have declared an if-else statement in this example.
02:48 First I declare a local variable my_num and assign the value of -1 to it.
02:55 Then I declare an if statement.
02:58 The if statement will check if the value of my_num is greater than 0.
03:03 If it is, it will print out the specified string.
03:06 If not, it will go to the else statement.
03:10 And it will print out the string that is specified there.
03:13 Now, let us switch to the terminal and type:
03:18 ruby space if hyphen else hyphen statement dot rb
03:26 and see the output.
03:27 The output will display “The value of my_num is lesser than 0”.
03:32 This shows that the else statement was executed.
03:35 You should now be able to write your own if-else statement in Ruby.
03:41 Let's look at the if-elsif statement next.
03:45 The syntax for using elsif is:
03:48 if “condition” ruby code
03:50 elsif “condition” ruby code
03:52 else ruby code
03:54 end
03:55 Let us look at an example.
03:58 Create a new file in gedit as shown in the basic level Ruby tutorials.
04:01 Name it if hyphen elsif hyphen statement dot rb.
04:07 I have a working example of the if-elsif- statement.
04:10 You can pause the tutorial and type the code as we go through it.
04:14 I have declared an if-elsif statement in this example.
04:19 Here also, I have declared a local variable my_num and assigned the value -1 to it.
04:25 Then I declare an if statement.
04:28 The if statement will check if the value of my_num is greater than 0.
04:32 If it is, it will print out the specified string.
04:35 If this is not true, it will go into the elsif section.
04:39 It will now check if the value of my_num is equal to -1.
04:43 If it is true, it will print out the string that is specified there.
04:46 The value of my_num is neither greater than 0 nor equal to -1. It will go into the else section.
04:54 But, since the value of my_num = -1 it will not proceed to the else block.
05:00 And, it will exit the conditional statement.
05:03 Now, let us switch to the terminal and type:
05:07 ruby space if hyphen elsif hyphen statement dot rb
05:15 and see the output.
05:17 The output will display “The value of my_num is -1 and is lesser than 0”.
05:23 Let's go back to our file and change the value of my_num to 5.
05:29 Let's save the code and execute it on the terminal.
05:35 So, now it fulfills the if condition and the specified string is printed.
05:42 "The value of my_num is greater than 0".
05:45 Let's go back to our file and change the value of my_num to -5.
05:50 Let's save the code and execute it on the terminal.
05:55 In this case, it fulfills the else condition and the puts statement within the else block gets executed.
06:03 You should now be able to write your own if-elsif statement in Ruby.
06:08 Let us look at the 'case' statement next.
06:12 The 'case' statement is a control flow statement based on a particular selection.
06:17 Let us look at the syntax of the 'case' statement in order to understand this statement.
06:22 The syntax for using case is:
06:24 case variable
06:26 when “value 1”
06:28 ruby code
06:29 when “value 2”
06:30 ruby code
06:31 else
06:32 ruby code
06:34 end
06:35 Let us look at an example.
06:37 Create a new file in gedit as shown in the basic level Ruby tutorials.
06:41 Name it case hyphen statement dot rb.
06:44 I have a working example of the 'case' statement.
06:48 You can pause the tutorial and type the code as we go through it.
06:52 I have declared a case statement in this example.
06:55 Here, I have a print statement which will print a question on the terminal.
07:01 Then I call a gets which will accept a single line of data from the standard input.
07:09 Then I strip the input data of any new line characters using chomp.
07:15 I assign the result to a variable named domain.
07:18 Then I declare a case statement.
07:22 Within that, I declare a when statement .
07:25 This checks whether the specified string matches the value of domain.
07:30 First, it checks whether the value of domain is “UP”.
07:34 If it is so, it will print out “Uttar Pradesh” and exit the case statement.
07:39 If domain is not “UP”, it checks whether the value of domain is “MP”.
07:44 If it is so, it will print out “Madhya Pradesh” and so on.
07:48 It will continue checking the value of domain if no match was found so far.
07:53 At this point, it will encounter the else statement
07:56 as none of the above conditions were true.
07:59 It will subsequently execute the ruby code that follows the else declaration.
08:03 It will print “Unknown” as per our example.
08:07 Now, save the file. Switch to the terminal and type:
08:11 ruby space case hyphen statement dot rb.
08:18 “Enter the state you live in:” will be displayed on the terminal.
08:22 Type in “UP” and see the output.
08:25 The output will display “Uttar Pradesh”.
08:28 Next, execute the Ruby file again, like before.
08:31 This time, at the prompt, type: “KL” and see the output.
08:36 It will print “Kerala”.
08:38 Next, execute the file one more time.
08:41 This time, at the prompt, type: in “TN” and see the output.
08:47 It will print “Unknown”.
08:50 This is because none of the cases were satisfied. So, the default else statement is executed.
08:58 You should now be able to write your own case-statements in Ruby.
09:03 ಇದರೊಂದಿಗೆ, ನಾವು ಈ ಸ್ಪೋಕನ್ ಟ್ಯುಟೋರಿಯಲ್ ನ ಕೊನೆಗೆ ಬಂದಿರುತ್ತೇವೆ.
09:07 ಸಂಕ್ಷಿಪ್ತವಾಗಿ,
09:08 ಈ ಟ್ಯುಟೋರಿಯಲ್ ನಲ್ಲಿ, we have learnt to use:
09:10 * if statement
09:12 * else construct
09:13 * if-elsif and
09:15 * case statements ನಾವು ಕಲಿತಿದ್ದೇವೆ.
09:17 ಒಂದು ಅಸೈನ್ಮೆಂಟ್ -
09:18 Write a Ruby program
09:20 that prompts a user to enter a number,
09:23 then use the appropriate control-statement
09:26 to check if the number is a multiple of 2.
09:29 If it is, then print: “The number entered is a multiple of 2”.
09:35 If not, it should check- if it is a multiple of 3.
09:38 If it is, then print: “The number entered is a multiple of 3”.
09:43 If not, it should check if it is a multiple of 4.
09:47 If it is, then print: “The number entered is a multiple of 4”.
09:51 If not, it should print: “The number is not a multiple of 2, 3 or 4”.
09:56 ಈ ಕೆಳಗಿನ ಲಿಂಕ್ ನಲ್ಲಿ ಲಭ್ಯವಿರುವ ವೀಡಿಯೋವನ್ನು ವೀಕ್ಷಿಸಿ.
10:00 ಇದು “ಸ್ಪೋಕನ್ ಟ್ಯುಟೋರಿಯಲ್” ಪ್ರಕಲ್ಪದ ಸಾರಾಂಶವಾಗಿದೆ.
10:03 ನಿಮಗೆ ಒಳ್ಳೆಯ ‘ಬ್ಯಾಂಡ್ವಿಡ್ತ್’ ಸಿಗದಿದ್ದರೆ, ನೀವು ಇದನ್ನು ಡೌನ್ಲೋಡ್ ಮಾಡಿ ನೋಡಬಹುದು.
10:07 “ಸ್ಪೋಕನ್ ಟ್ಯುಟೋರಿಯಲ್” ಪ್ರಕಲ್ಪದ ತಂಡವು:
10:09 * ‘ಸ್ಪೋಕನ್ ಟ್ಯುಟೋರಿಯಲ್’ಗಳನ್ನು ಬಳಸಿ ಕಾರ್ಯಶಾಲೆಗಳನ್ನು ನಡೆಸುತ್ತದೆ.
10:13 * ಆನ್-ಲೈನ್ ಪರೀಕ್ಷೆಯಲ್ಲಿ ಉತ್ತೀರ್ಣರಾದವರಿಗೆ ಪ್ರಮಾಣಪತ್ರವನ್ನು ಕೊಡುತ್ತದೆ.
10:16 ಹೆಚ್ಚಿನ ಮಾಹಿತಿಗಾಗಿ, ದಯವಿಟ್ಟು ಈ ಲಿಂಕ್ ಗೆ ಬರೆಯಿರಿ:

contact@spoken-tutorial.org

10:21 "ಸ್ಪೋಕನ್ ಟ್ಯುಟೋರಿಯಲ್" ಪ್ರಕಲ್ಪವು “ಟಾಕ್ ಟು ಎ ಟೀಚರ್” ಪ್ರಕಲ್ಪದ ಒಂದು ಭಾಗವಾಗಿದೆ.
10:26 ಇದು ICT, MHRD ಮೂಲಕ ರಾಷ್ಟ್ರೀಯ ಸಾಕ್ಷರತಾ ಮಿಷನ್, ಭಾರತ ಸರ್ಕಾರದ ಆಧಾರವನ್ನು ಪಡೆದಿದೆ.
10:32 ಈ ಮಿಷನ್ ನ ಬಗ್ಗೆ ಹೆಚ್ಚಿನ ಮಾಹಿತಿಯು ಈ ಕೆಳಗಿನ ಲಿಂಕ್ ನಲ್ಲಿ ಲಭ್ಯವಿರುತ್ತದೆ:

spoken hyphen tutorial dot org slash NMEICT hyphen Intro.

10:41 IIT Bombay ಯಿಂದ, ಸ್ಕ್ರಿಪ್ಟ್ ನ ಅನುವಾದಕಿ ಸಂಧ್ಯಾ ಪುಣೇಕರ್ ಹಾಗೂ ಪ್ರವಾಚಕ ----------- . ವಂದನೆಗಳು.

Outline: Control Statements in Ruby

   What are control statements
   Syntax for
       if statement
       if..else statement
       if..elsif statement
       Examples on it
   Ternary Operator
   Syntax for case statement and example on it
   Comparison between if..elsif and case statement

END 6 ---------------------------------------

Contributors and Content Editors

NaveenBhat, Sandhya.np14