Difference between revisions of "Ruby/C2/Ruby-Methods/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with ''''Title of script''': Ruby Methods '''Author:'''Afrin Pinjari '''Keywords: '''method,method syntax, return, video tutorial {| style="border-spacing:0;" ! <center>Visual Cue…')
 
Line 24: Line 24:
 
* Syntax for '''method''' and
 
* Syntax for '''method''' and
 
* Some examples
 
* Some examples
 
 
  
 
|-
 
|-
Line 35: Line 33:
 
* '''Ubuntu Linux '''version 12.04  
 
* '''Ubuntu Linux '''version 12.04  
 
* '''Ruby''' 1.9.3
 
* '''Ruby''' 1.9.3
 
 
  
 
|-
 
|-
Line 49: Line 45:
 
What is Methods
 
What is Methods
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us now start with an introduction to '''methods.'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us now start with an introduction to '''methods.'''
 
  
 
A '''Method''' is a self-contained program executing a specific task.  
 
A '''Method''' is a self-contained program executing a specific task.  
 
  
 
'''Ruby method''' is very similar to functions in any other programming language.
 
'''Ruby method''' is very similar to functions in any other programming language.
 
 
 
  
 
|-
 
|-
Line 64: Line 55:
 
Method
 
Method
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Method''' name should begin with a lowercase letter.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Method''' name should begin with a lowercase letter.
 
  
 
'''Methods''' should be defined before calling them.
 
'''Methods''' should be defined before calling them.
Line 73: Line 63:
 
Syntax for Method
 
Syntax for Method
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us see the syntax of '''Method'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us see the syntax of '''Method'''
 
  
 
'''def method_name(arguments)'''
 
'''def method_name(arguments)'''
Line 82: Line 71:
  
 
'''OR'''
 
'''OR'''
 
  
 
'''def method_name ()'''
 
'''def method_name ()'''
Line 117: Line 105:
  
 
'''method''' .'' ''
 
'''method''' .'' ''
 
  
 
The word end marks end of method
 
The word end marks end of method
 
  
 
This is called as method without arguments.
 
This is called as method without arguments.
Line 127: Line 113:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch to the editor – gedit.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch to the editor – gedit.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let's see how to use a method.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let's see how to use a method.
 
  
 
I have already typed a program in the '''gedit''' editor.  
 
I have already typed a program in the '''gedit''' editor.  
Line 136: Line 121:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Point to the filename on the Title bar.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Point to the filename on the Title bar.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Please note that our filename is '''method-without-argument.rb'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Please note that our filename is '''method-without-argument.rb'''
 
  
 
I have saved the file inside our '''rubyprogram''' folder.
 
I have saved the file inside our '''rubyprogram''' folder.
Line 143: Line 127:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| In this program we will calculate the sum of two numbers using '''method'''.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| In this program we will calculate the sum of two numbers using '''method'''.
 
 
 
  
 
|-
 
|-
Line 153: Line 134:
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight''' $a=5 '''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight''' $a=5 '''
 
 
 
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here we have declared a global variable '''a.'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here we have declared a global variable '''a.'''
 
  
 
And we have initialized it by assigning value of '''5'''.  
 
And we have initialized it by assigning value of '''5'''.  
 
  
 
Global variable names are prefixed with a''' dollar sign ($)'''.''' '''
 
Global variable names are prefixed with a''' dollar sign ($)'''.''' '''
Line 167: Line 143:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Global variables are accessible from anywhere in the '''Ruby''' program;
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Global variables are accessible from anywhere in the '''Ruby''' program;
 
  
 
regardless of where they are declared.
 
regardless of where they are declared.
Line 194: Line 169:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''b'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''b'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The converted value is stored in the variable '''b .'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The converted value is stored in the variable '''b .'''
 
  
 
'''b '''is a local variable.
 
'''b '''is a local variable.
 
  
 
It is available only to the '''method''' inside which it is declared.
 
It is available only to the '''method''' inside which it is declared.
Line 204: Line 177:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''sum=$a+b'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''sum=$a+b'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here we add the values of global variable '''a '''and variable '''b.'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here we add the values of global variable '''a '''and variable '''b.'''
 
  
 
The result is stored in variable '''sum.'''
 
The result is stored in variable '''sum.'''
Line 211: Line 183:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''puts"Sum of#{ $a} & #{b} is #{sum}"'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''puts"Sum of#{ $a} & #{b} is #{sum}"'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Then we print the '''sum.'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Then we print the '''sum.'''
 
 
 
  
 
|-
 
|-
Line 248: Line 217:
  
 
This program will be saved in''' rubyprogram''' folder as mentioned earlier.
 
This program will be saved in''' rubyprogram''' folder as mentioned earlier.
 
  
 
Now let us execute the program.
 
Now let us execute the program.
Line 254: Line 222:
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Press '''Ctrl+Alt+t'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Press '''Ctrl+Alt+t'''
 
  
 
'''Switch to Terminal'''
 
'''Switch to Terminal'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Open the terminal by pressing the '''Ctrl, Alt and T '''keys simultaneously.  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Open the terminal by pressing the '''Ctrl, Alt and T '''keys simultaneously.  
 
  
 
A terminal window appears on the screen.
 
A terminal window appears on the screen.
Line 285: Line 251:
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''Sum of two numbers 5 and 4 is 9'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''Sum of two numbers 5 and 4 is 9'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output as -  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We get the output as -  
 
  
 
'''Sum of two numbers 5 and 4 is 9'''
 
'''Sum of two numbers 5 and 4 is 9'''
Line 294: Line 259:
  
 
I have already typed this program in the '''gedit''' editor, so let me open it.
 
I have already typed this program in the '''gedit''' editor, so let me open it.
 
 
 
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Point to the filename in the '''Title bar.'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Point to the filename in the '''Title bar.'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Please note that our filename is '''method-with-argument.rb'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Please note that our filename is '''method-with-argument.rb'''
 
  
 
I have saved this file also inside the '''rubyprogram''' folder.
 
I have saved this file also inside the '''rubyprogram''' folder.
Line 332: Line 293:
 
'''b=gets.to_i'''
 
'''b=gets.to_i'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here we are asking the user for input.  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here we are asking the user for input.  
 
  
 
User will enter the values of a and b.  
 
User will enter the values of a and b.  
 
  
 
The values will be stored in variable '''a''' and variable '''b, '''respectively.
 
The values will be stored in variable '''a''' and variable '''b, '''respectively.
Line 355: Line 314:
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch back to terminal
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch back to terminal
 
  
 
Type '''clear'''<nowiki><<Press Enter </nowiki>
 
Type '''clear'''<nowiki><<Press Enter </nowiki>
 
 
  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Lets execute this code.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Lets execute this code.
Line 380: Line 336:
  
 
Replace '''method-without-arguments.rb''' with '''method-with-arguments.rb '''
 
Replace '''method-without-arguments.rb''' with '''method-with-arguments.rb '''
 
  
 
Press''' Enter'''
 
Press''' Enter'''
Line 399: Line 354:
  
 
'''Sum of two numbers 8 and 9 is 17.'''
 
'''Sum of two numbers 8 and 9 is 17.'''
 
  
 
<nowiki><<pause>></nowiki>
 
<nowiki><<pause>></nowiki>
Line 421: Line 375:
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch back to terminal
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Switch back to terminal
 
 
 
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let's execute the code.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let's execute the code.
 
  
 
Go to the terminal.
 
Go to the terminal.
Line 434: Line 384:
 
'''ruby method-with-argument.rb '''<nowiki><< Press</nowiki>''' Enter'''
 
'''ruby method-with-argument.rb '''<nowiki><< Press</nowiki>''' Enter'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Press the up arrow key to get the previous command.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Press the up arrow key to get the previous command.
 
  
 
Press''' Enter.'''
 
Press''' Enter.'''
Line 474: Line 423:
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 11
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 11
 
  
 
Summary
 
Summary
Line 480: Line 428:
  
 
Let's summarize
 
Let's summarize
 
  
 
In this tutorial we have learnt
 
In this tutorial we have learnt
Line 489: Line 436:
 
* '''Method''' with arguments
 
* '''Method''' with arguments
 
* Returning value from '''method'''<br/>  
 
* Returning value from '''method'''<br/>  
 
 
 
  
 
|-
 
|-
Line 504: Line 448:
 
* by using '''method '''and
 
* by using '''method '''and
 
* by getting the input from user  
 
* by getting the input from user  
 
 
  
 
|-
 
|-
Line 512: Line 454:
 
About the Spoken Tutorial Project
 
About the Spoken Tutorial Project
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Watch the video available at the following link.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Watch the video available at the following link.
 
  
 
It summarises the Spoken Tutorial project.
 
It summarises the Spoken Tutorial project.
Line 532: Line 473:
  
 
[mailto:contact@spoken-tutorial.org contact@spoken-tutorial.org]
 
[mailto:contact@spoken-tutorial.org contact@spoken-tutorial.org]
 
 
 
  
 
|-
 
|-

Revision as of 13:34, 26 February 2013

Title of script: Ruby Methods

Author:Afrin Pinjari

Keywords: method,method syntax, return, video tutorial


Visual Cue
Narration
Slide 1 Welcome to the Spoken Tutorial on Ruby Methods.
Slide 2

Learning Objective

In this tutorial we will learn
  • What is a method ?
  • Syntax for method and
  • Some examples
Slide 3

System Requirement

Here we are using
  • Ubuntu Linux version 12.04
  • Ruby 1.9.3
Slide 4

Pre-requisites

To follow this tutorial you must have knowledge of using Terminal and Text editor in Linux.
Slide 5

What is Methods

Let us now start with an introduction to methods.

A Method is a self-contained program executing a specific task.

Ruby method is very similar to functions in any other programming language.

Slide 6

Method

Method name should begin with a lowercase letter.

Methods should be defined before calling them.

Slide 7

Syntax for Method

Let us see the syntax of Method

def method_name(arguments)

ruby code

end

OR

def method_name ()

ruby code

end


Methods are defined using the keyword def followed by the method name.


The arguments specify values that are passed to the method, to be processed.


The ruby code section represents the body of the

method that performs the processing.


The method body is enclosed by this definition on the top and the word end on the bottom

This is called as method with arguments.

Slide 7 Another syntax for method is


The keyword def followed by the method name and an empty argument list


The ruby code section represents the body of the

method .

The word end marks end of method

This is called as method without arguments.

Switch to the editor – gedit. Let's see how to use a method.

I have already typed a program in the gedit editor.

Let me open it.

Point to the filename on the Title bar. Please note that our filename is method-without-argument.rb

I have saved the file inside our rubyprogram folder.

In this program we will calculate the sum of two numbers using method.
Let us go through the program.
Highlight $a=5 Here we have declared a global variable a.

And we have initialized it by assigning value of 5.

Global variable names are prefixed with a dollar sign ($).

Global variables are accessible from anywhere in the Ruby program;

regardless of where they are declared.

Highlight def add() Here we have declared a method add without any arguments.
Highlight print"Enter the second number:" Here we ask the user to enter the second number.
Highlight b=gets.to_i User will enter the value.
Highlight gets gets method gets user input from the console but in string format.
Highlight to_i So we need to convert it into integer, using to_i method.
Highlight b The converted value is stored in the variable b .

b is a local variable.

It is available only to the method inside which it is declared.

Highlight sum=$a+b Here we add the values of global variable a and variable b.

The result is stored in variable sum.

Highlight puts"Sum of#{ $a} & #{b} is #{sum}" Then we print the sum.
Highlight #{sum} This shows a way of inserting a variable within a string.

Here the content of sum is returned as a string and is

substituted into the outer string.

Highlight end end marks end of the method.
There are two types of methods.

User-defined method - that is our add method.

Pre-defined method - that is print, gets and to_i method.

Highlight add() Here we call the add method.

The addition operation will be performed and the result will be

printed.

Click on Save. Now let us click on Save.

This program will be saved in rubyprogram folder as mentioned earlier.

Now let us execute the program.

Press Ctrl+Alt+t

Switch to Terminal

Open the terminal by pressing the Ctrl, Alt and T keys simultaneously.

A terminal window appears on the screen.

To execute the program, we need to go to the subdirectory rubyprogram.
Type cd Desktop/rubyprogram<< Press Enter So let's type cd space Desktop/rubyprogram and press Enter.
Type ruby method-without-argument.rb <<Press Enter Type ruby space method-without-argument.rb and press Enter
Enter the second number is displayed.

I will enter value as 4.

type 4 and press enter

Highlight Sum of two numbers 5 and 4 is 9 We get the output as -

Sum of two numbers 5 and 4 is 9

Switch back to editor Now let us see an example of method with arguments.

I have already typed this program in the gedit editor, so let me open it.

Point to the filename in the Title bar. Please note that our filename is method-with-argument.rb

I have saved this file also inside the rubyprogram folder.

Let us go through the program.
Highlight def add(a ,b) Here we have declared a method called add.

a,b are the arguments of the method add.

Highlight return a+b Here the values of a and b are added.

And the sum is returned to the method call.

Highlight end end marks the end of method.
Highlight puts"Enter the values of a and b"

a=gets.to_i

b=gets.to_i

Here we are asking the user for input.

User will enter the values of a and b.

The values will be stored in variable a and variable b, respectively.

Highlight c=add(a,b) Here we call the method add

Then we pass the arguments as a and b.

Highlight c The value returned by the method add , after performing the addition operation will be stored in c.
Highlight puts"Sum of two number #{a} and #{b} is #{c}" Here we print the sum which is store in c.
Switch back to terminal

Type clear<<Press Enter

Lets execute this code.

Go to the terminal.

Let us first clear the terminal

Type clear and press enter

Point to the command prompt to show subdirectory rubyprogram We are already in the subdirectory rubyprogram.
Replace

ruby method-with-argument.rb << Press Enter

Now, press the up arrow key twice to get the previous command.

Replace method-without-arguments.rb with method-with-arguments.rb

Press Enter

Enter the values of a and b is displayed.

I will enter 8 and 9.

Type 8 and press Enter

Type 9 and press Enter

Highlight Sum of two numbers 8 and 9 is 17 We get the output as

Sum of two numbers 8 and 9 is 17.

<<pause>>

Now I will show you one important feature of Ruby method.
Switch back to the text editor Let's go back to the program in the text editor.
Delete the keyword return.
Click on Save Now click on Save button.
Switch back to terminal Let's execute the code.

Go to the terminal.

Replace

ruby method-with-argument.rb << Press Enter

Press the up arrow key to get the previous command.

Press Enter.

Enter the values of a and b is displayed.

I will enter 10 and 15.

Type 10 and press Enter

Type 15 and press Enter

Highlight Sum of two numbers 10 and 15 is 25 We get the output as

Sum of two numbers10 and 15 is 25.

We can see that the program is executed without any error, even after deleting the keyword return.
Switch back to the program

Highlight a+b

This is because Ruby automatically returns the value calculated in the method.

The keyword return in method is optional in Ruby.

<<Pause>>

This brings us to the end of this Spoken Tutorial.

Slide 11

Summary

Let us switch back to slides

Let's summarize

In this tutorial we have learnt

  • About Methods
  • Syntax
  • Method without arguments
  • Method with arguments
  • Returning value from method
Slide 13

Assignment

As an assignment

Write a program

  • to calculate area of a square
  • by using method and
  • by getting the input from user
Slide 14

About the Spoken Tutorial Project

Watch the video available at the following link.

It summarises the Spoken Tutorial project.

If you do not have good bandwidth, you can download and

watch it.

Slide 15 The Spoken Tutorial Project Team :


Conducts workshops using spoken tutorials

Gives certificates to those who pass an online test

For more details, please write to

contact@spoken-tutorial.org

Slide 16


Acknowledgement

Spoken Tutorial Project is a part of the Talk to a Teacher project.

It is supported by the National Mission on Education through ICT, MHRD, Government of India.

More information on this Mission is available at:

spoken-tutorial.org/NMEICT-Intro.

This is Afrin Pinjari from IIT Bombay, signing off.

Thank you for watching.

Contributors and Content Editors

Afrin, Nancyvarkey, Sneha