Difference between revisions of "Python/C2/Using-sage-to-teach/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| border=1 !Timing !Narration |- |0:02 | Hello friends and welcome to the tutorial on 'Using SAGE to teach'. |- | 0:07 | At the end of this tutorial, you will be able to, # U…')
 
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{| border=1
 
{| border=1
!Timing
+
|'''Time'''
!Narration
+
|'''Narration'''
 +
 
 
|-
 
|-
|0:02
+
|00:02
 
| Hello friends and welcome to the tutorial on 'Using SAGE to teach'.
 
| Hello friends and welcome to the tutorial on 'Using SAGE to teach'.
  
 
|-
 
|-
0:07
+
00:07
 
| At the end of this tutorial, you will be able to,
 
| At the end of this tutorial, you will be able to,
 
+
Use @interact feature of SAGE for better demonstration.
# Use <tt>@interact</tt> feature of SAGE for better demonstration.
+
Share, publish and edit SAGE worksheets for collaborative learning.
# Share, publish and edit SAGE worksheets for collaborative learning.
+
  
 
|-
 
|-
0:19
+
00:19
 
| Before beginning this tutorial,we would suggest you to complete the tutorial on "Getting started with Sage" and "Getting started with Symbolics."
 
| Before beginning this tutorial,we would suggest you to complete the tutorial on "Getting started with Sage" and "Getting started with Symbolics."
  
 
|-
 
|-
| 0:30
+
| 00:30
 
| Let us start by looking at a typical example of demonstrating a damped oscillation.
 
| Let us start by looking at a typical example of demonstrating a damped oscillation.
  
 
|-
 
|-
|0:40
+
|00:40
 
|So you can type t=var('t') ,then next line you can type p1=plot (e raised to minus (-t)into sin of (2 into t),(t,0,15))
 
|So you can type t=var('t') ,then next line you can type p1=plot (e raised to minus (-t)into sin of (2 into t),(t,0,15))
  
 
|-
 
|-
|1:06
+
|01:06
 
|then third line you can type show(p1)
 
|then third line you can type show(p1)
  
 
|-
 
|-
| 1:17
+
| 01:17
 
| Now let us reduce the damping factor by half
 
| Now let us reduce the damping factor by half
  
 
|-
 
|-
|1:23
+
|01:23
 
|so for that you have to type t=var('t')
 
|so for that you have to type t=var('t')
  
 
|-
 
|-
|1:33
+
|01:33
 
|then p1=plot(e raised to (-t by 2) * sin(2 into t),(t,0,15))
 
|then p1=plot(e raised to (-t by 2) * sin(2 into t),(t,0,15))
  
 
|-
 
|-
|1:48
+
|01:48
 
|then third line you can type show(p1)
 
|then third line you can type show(p1)
  
 
|-
 
|-
| 1:53
+
| 01:53
 
| Now, if we want to reduce the damping factor even more, we would be using e charat to (-t by 3).
 
| Now, if we want to reduce the damping factor even more, we would be using e charat to (-t by 3).
  
 
|-
 
|-
|2:04
+
|02:04
 
| We can observe that every time we have to change, all we do is change something very small and re-evaluate the cell.
 
| We can observe that every time we have to change, all we do is change something very small and re-evaluate the cell.
  
 
|-
 
|-
|2:10
+
|02:10
|This process can be simplified, using the <tt>@interact</tt> feature of SAGE.
+
|This process can be simplified, using the @interact feature of SAGE.
  
 
|-
 
|-
|2:17
+
|02:17
|So you can type <tt>@interact</tt> ,then def plot_damped(n-1):
+
|So you can type @interact ,then def plot_damped(n-1):
  
 
|-
 
|-
|2:32
+
|02:32
 
|Then, t=var('t')
 
|Then, t=var('t')
  
 
|-
 
|-
|2:49
+
|02:49
 
|p1=plot (e raised to(-t/n) * sin(2*t),(t,0,20))
 
|p1=plot (e raised to(-t/n) * sin(2*t),(t,0,20))
  
 
|-
 
|-
|3:01
+
|03:01
 
|then type show(p1)
 
|then type show(p1)
  
 
|-
 
|-
3:11
+
03:11
 
| We can see that the function is evaluated and the plot is shown.
 
| We can see that the function is evaluated and the plot is shown.
  
 
|-
 
|-
|3:15
+
|03:15
| We can also see that there is a field to enter the value of <tt>n</tt> and it is currently set to <tt>1</tt>.
+
| We can also see that there is a field to enter the value of n and it is currently set to 1 .
  
 
|-
 
|-
|3:21
+
|03:21
 
| Let us change it to 2 and hit enter.
 
| Let us change it to 2 and hit enter.
  
 
|-
 
|-
|3:23
+
|03:23
 
|So you type 2 and hit enter.
 
|So you type 2 and hit enter.
  
 
|-
 
|-
| 3:29
+
| 03:29
 
| We see that the new plot with reduced damping factor is shown.
 
| We see that the new plot with reduced damping factor is shown.
  
 
|-
 
|-
| 3:33
+
| 03:33
| Similarly we can change <tt>n</tt> to any desired value and hit enter and the function will be evaluated.
+
| Similarly we can change n to any desired value and hit enter and the function will be evaluated.
  
 
|-
 
|-
|3:41
+
|03:41
 
|This is a very handy tool while demonstrating or teaching.
 
|This is a very handy tool while demonstrating or teaching.
  
 
|-
 
|-
|3:45
+
|03:45
 
|Pause the video here, try out the following exercise and resume the video.
 
|Pause the video here, try out the following exercise and resume the video.
  
 
|-
 
|-
| 3:50
+
| 03:50
| '''Plot the sine curve and vary its frequency using the <tt>@interact'''</tt> feature.
+
| '''Plot the sine curve and vary its frequency using the @interact'' feature.
  
 
|-
 
|-
| 3:57
+
| 03:57
 
| Now, switch to your worksheet for solution.
 
| Now, switch to your worksheet for solution.
  
 
|-
 
|-
|4:03
+
|04:03
 
|You can type @interact
 
|You can type @interact
  
 
|-
 
|-
|4:08
+
|04:08
 
|then def sine_plot(n=1):
 
|then def sine_plot(n=1):
  
 
|-
 
|-
|4:12
+
|04:12
 
|then x=var('x')
 
|then x=var('x')
  
 
|-
 
|-
|4:18
+
|04:18
 
|then p2=plot (sin(n*x),(x,0,2*pi))
 
|then p2=plot (sin(n*x),(x,0,2*pi))
  
 
|-
 
|-
|4:27
+
|04:27
 
|then finally you can type show(p2)
 
|then finally you can type show(p2)
  
 
|-
 
|-
|4:43
+
|04:43
 
|So often we would want to vary a parameter over range instead of taking it as an input from the user.
 
|So often we would want to vary a parameter over range instead of taking it as an input from the user.
  
 
|-
 
|-
| 4:51
+
| 04:51
| For instance we would not want the user to give <tt>n</tt> as 0 for the damping oscillation we discussed.
+
| For instance we would not want the user to give n as 0 for the damping oscillation we discussed.
  
 
|-
 
|-
|4:56
+
|04:56
 
| In such cases we use a range of values as the default argument.
 
| In such cases we use a range of values as the default argument.
  
 
|-
 
|-
|5:02
+
|05:02
 
|at the rate interact
 
|at the rate interact
  
 
|-
 
|-
|5:10
+
|05:10
 
|should be typed in the worksheet so in the worksheet you can type
 
|should be typed in the worksheet so in the worksheet you can type
  
 
|-
 
|-
|5:14
+
|05:14
 
|@interact then def plot underscore damped(n=(1..10)):
 
|@interact then def plot underscore damped(n=(1..10)):
  
 
|-
 
|-
|5:28
+
|05:28
 
|then next line you can type t=var('t')
 
|then next line you can type t=var('t')
  
 
|-
 
|-
|5:36
+
|05:36
 
|then p1=plot(e raised to (-t/n) * sin(2*t)),(t,0,20))
 
|then p1=plot(e raised to (-t/n) * sin(2*t)),(t,0,20))
  
 
|-
 
|-
|5:52
+
|05:52
 
|then you can type show(p1)
 
|then you can type show(p1)
  
 
|-
 
|-
|6:08
+
|06:08
 
|Now we had seen an error
 
|Now we had seen an error
  
 
|-
 
|-
|6:12
+
|06:12
|So the error that we have rectified is after sin(2*t) we have accidently placed an extra bracket.
+
|So the error that we have rectified is after sin(2*t) we have accidentally placed an extra bracket.
  
 
|-
 
|-
| 6:25
+
| 06:25
 
| So we get similar plot but the only difference is the input widget.
 
| So we get similar plot but the only difference is the input widget.
  
 
|-
 
|-
|6:30
+
|06:30
 
| Here it is a slider unlike an input field.
 
| Here it is a slider unlike an input field.
  
 
|-
 
|-
| 6:35
+
| 06:35
 
| We can see that the slider is moved, the function is evaluated and plotted accordingly.
 
| We can see that the slider is moved, the function is evaluated and plotted accordingly.
  
 
|-
 
|-
|6:48
+
|06:48
 
|Pause the video here,and try out the following exercise and resume the video.
 
|Pause the video here,and try out the following exercise and resume the video.
  
 
|-
 
|-
| 6:52
+
| 06:52
 
| '''Take a string as input from user and circular shift it to the left and''' vary the shift length using a slider.
 
| '''Take a string as input from user and circular shift it to the left and''' vary the shift length using a slider.
  
 
|-
 
|-
| 7:03
+
| 07:03
| For this problem, again we will use the <tt>@interact</tt> feature of sage.  
+
| For this problem, again we will use the @interact feature of sage.  
  
 
|-
 
|-
|7:09
+
|07:09
 
|We shall first assign a string say 'MADAM' to a variable and then shift the alphabets one by one.
 
|We shall first assign a string say 'MADAM' to a variable and then shift the alphabets one by one.
  
 
|-
 
|-
|7:17
+
|07:17
 
|So we can type @interact
 
|So we can type @interact
  
 
|-
 
|-
|7:21
+
|07:21
 
|def str_shift(s="MADAM", shift=(0..8)) colon
 
|def str_shift(s="MADAM", shift=(0..8)) colon
  
 
|-
 
|-
|7:33
+
|07:33
 
|then you can type shift_len=shift modulus len(s)
 
|then you can type shift_len=shift modulus len(s)
  
 
|-
 
|-
|7:40
+
|07:40
 
|then chars=list(s)
 
|then chars=list(s)
  
 
|-
 
|-
|7:46
+
|07:46
 
|then shifted_chars=chars[shift_len:]+chars[: shift_len]
 
|then shifted_chars=chars[shift_len:]+chars[: shift_len]
  
 
|-
 
|-
|8:03
+
|08:03
 
|then print "Actual String:",s
 
|then print "Actual String:",s
  
 
|-
 
|-
|8:11
+
|08:11
 
|then print "Shifted String:", "".join(shifted_chars)
 
|then print "Shifted String:", "".join(shifted_chars)
  
 
|-
 
|-
| 8:28
+
|08:28
 
| As we move the slider, we see that shifting is taking place.
 
| As we move the slider, we see that shifting is taking place.
  
 
|-
 
|-
8:40
+
08:40
 
| Sometimes we want the user to have only a given set of options.
 
| Sometimes we want the user to have only a given set of options.
  
 
|-
 
|-
| 8:44
+
| 08:44
 
| We use a list of items as the default argument in such situations.
 
| We use a list of items as the default argument in such situations.
  
 
|-
 
|-
|8:50
+
|08:50
 
|So we can type @interact
 
|So we can type @interact
  
 
|-
 
|-
|8:57
+
|08:57
 
|then def str_shift(s="STRING",shift=(0..8), direction=["Left","Right"]):
 
|then def str_shift(s="STRING",shift=(0..8), direction=["Left","Right"]):
  
 
|-
 
|-
|9:10
+
|09:10
 
|then next line shift_len=shift modulus len(s)
 
|then next line shift_len=shift modulus len(s)
  
 
|-
 
|-
|9:24
+
|09:24
 
|then chars=list(s)
 
|then chars=list(s)
  
 
|-
 
|-
|9:26
+
|09:26
 
|if direction=="Right" colon
 
|if direction=="Right" colon
  
 
|-
 
|-
|9:32
+
|09:32
 
|then shifted_chars=chars[-shift_len colon]+chars[colon -shift_len]
 
|then shifted_chars=chars[-shift_len colon]+chars[colon -shift_len]
  
Line 295: Line 295:
 
|-
 
|-
 
|11:18
 
|11:18
|Thus, we have learnt how to use the <tt>@interact</tt> feature of SAGE for better demonstration.
+
|Thus, we have learnt how to use the @interact feature of SAGE for better demonstration.
  
 
|-
 
|-
Line 303: Line 303:
 
|-
 
|-
 
| 11:30
 
| 11:30
| The first feature we shall see is the <tt>publish</tt> feature.
+
| The first feature we shall see is the publish feature.
  
 
|-
 
|-
 
|11:34
 
|11:34
| Open a worksheet and in the top right, we can see a button called <tt>publish</tt>.
+
| Open a worksheet and in the top right, we can see a button called publish
 
+
 
|-
 
|-
 
|11:40
 
|11:40
Line 315: Line 314:
 
|-
 
|-
 
|11:52
 
|11:52
| For now lets forget that option and simply publish by clicking <tt>yes</tt>.  
+
| For now lets forget that option and simply publish by clicking yes .  
  
 
|-
 
|-
 
|11:58
 
|11:58
|The worksheet is now published.
+
|The worksheet is now published. Now lets sign out and go to the sage notebook home.  
 
+
|-
+
|11:59
+
|Now lets sign out and go to the sage notebook home.  
+
  
 
|-
 
|-
Line 355: Line 350:
 
|-
 
|-
 
| 12:51
 
| 12:51
| Let us open the worksheet and we see a link called <tt>share</tt> on the top right corner of the worksheet.  
+
| Let us open the worksheet and we see a link called share on the top right corner of the worksheet.  
  
 
|-
 
|-
Line 375: Line 370:
 
|-
 
|-
 
|13:24
 
|13:24
|In this tutorial, we have learnt to,
+
|In this tutorial, we have learnt to, Use interactive features of SAGE using @interact .
 
+
|-
+
|13:25
+
| Use interactive features of SAGE using <tt>@interact</tt>.
+
  
 
|-
 
|-
Line 399: Line 390:
 
|-
 
|-
 
|13:44
 
|13:44
|1. Which default argument, when used with <tt>@interact</tt> gives a slider starting at 0 and ending in 10.
+
| Which default argument, when used with @interact gives a slider starting at 0 and ending in 10.
  
 
|-
 
|-
Line 407: Line 398:
 
|-
 
|-
 
|13:54
 
|13:54
| then range(0, 11)
+
| then range(0, 11), Then [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] separated by comma  
 
+
|-
+
|13:55
+
| <nowiki>Then [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] </nowiki> separated by comma  
+
  
 
|-
 
|-
Line 419: Line 406:
 
|-
 
|-
 
|14:05
 
|14:05
|2. What is the input widget resulted by using <tt><nowiki>n = [2, 4, 5, 9]</nowiki></tt> in the default arguments along with <tt>@interact</tt>.
+
| What is the input widget resulted by using n = [2, 4, 5, 9]\ in the default arguments along with @interact.
  
 
|-
 
|-
Line 431: Line 418:
 
|-
 
|-
 
|14:31
 
|14:31
|1.The default argument, used with <tt>@interact</tt> which gives a slider starting at 0 and ending in 10 is (0..10).
+
|The default argument, used with @interact which gives a slider starting at 0 and ending in 10 is (0..10).
  
 
|-
 
|-
 
|14:42
 
|14:42
|2. The input widget resulted by using <tt><nowiki>n = [2, 4, 5, 9]</nowiki></tt> in the default arguments along with <tt>@interact</tt> will be a set of buttons that is the second one.
+
|The input widget resulted by using n = [2, 4, 5, 9] in the default arguments along with @interact will be a set of buttons that is the second one.
 
+
 
+
  
 
|-
 
|-

Latest revision as of 11:14, 27 March 2017

Time Narration
00:02 Hello friends and welcome to the tutorial on 'Using SAGE to teach'.
00:07 At the end of this tutorial, you will be able to,

Use @interact feature of SAGE for better demonstration. Share, publish and edit SAGE worksheets for collaborative learning.

00:19 Before beginning this tutorial,we would suggest you to complete the tutorial on "Getting started with Sage" and "Getting started with Symbolics."
00:30 Let us start by looking at a typical example of demonstrating a damped oscillation.
00:40 So you can type t=var('t') ,then next line you can type p1=plot (e raised to minus (-t)into sin of (2 into t),(t,0,15))
01:06 then third line you can type show(p1)
01:17 Now let us reduce the damping factor by half
01:23 so for that you have to type t=var('t')
01:33 then p1=plot(e raised to (-t by 2) * sin(2 into t),(t,0,15))
01:48 then third line you can type show(p1)
01:53 Now, if we want to reduce the damping factor even more, we would be using e charat to (-t by 3).
02:04 We can observe that every time we have to change, all we do is change something very small and re-evaluate the cell.
02:10 This process can be simplified, using the @interact feature of SAGE.
02:17 So you can type @interact ,then def plot_damped(n-1):
02:32 Then, t=var('t')
02:49 p1=plot (e raised to(-t/n) * sin(2*t),(t,0,20))
03:01 then type show(p1)
03:11 We can see that the function is evaluated and the plot is shown.
03:15 We can also see that there is a field to enter the value of n and it is currently set to 1 .
03:21 Let us change it to 2 and hit enter.
03:23 So you type 2 and hit enter.
03:29 We see that the new plot with reduced damping factor is shown.
03:33 Similarly we can change n to any desired value and hit enter and the function will be evaluated.
03:41 This is a very handy tool while demonstrating or teaching.
03:45 Pause the video here, try out the following exercise and resume the video.
03:50 'Plot the sine curve and vary its frequency using the @interact feature.
03:57 Now, switch to your worksheet for solution.
04:03 You can type @interact
04:08 then def sine_plot(n=1):
04:12 then x=var('x')
04:18 then p2=plot (sin(n*x),(x,0,2*pi))
04:27 then finally you can type show(p2)
04:43 So often we would want to vary a parameter over range instead of taking it as an input from the user.
04:51 For instance we would not want the user to give n as 0 for the damping oscillation we discussed.
04:56 In such cases we use a range of values as the default argument.
05:02 at the rate interact
05:10 should be typed in the worksheet so in the worksheet you can type
05:14 @interact then def plot underscore damped(n=(1..10)):
05:28 then next line you can type t=var('t')
05:36 then p1=plot(e raised to (-t/n) * sin(2*t)),(t,0,20))
05:52 then you can type show(p1)
06:08 Now we had seen an error
06:12 So the error that we have rectified is after sin(2*t) we have accidentally placed an extra bracket.
06:25 So we get similar plot but the only difference is the input widget.
06:30 Here it is a slider unlike an input field.
06:35 We can see that the slider is moved, the function is evaluated and plotted accordingly.
06:48 Pause the video here,and try out the following exercise and resume the video.
06:52 Take a string as input from user and circular shift it to the left and vary the shift length using a slider.
07:03 For this problem, again we will use the @interact feature of sage.
07:09 We shall first assign a string say 'MADAM' to a variable and then shift the alphabets one by one.
07:17 So we can type @interact
07:21 def str_shift(s="MADAM", shift=(0..8)) colon
07:33 then you can type shift_len=shift modulus len(s)
07:40 then chars=list(s)
07:46 then shifted_chars=chars[shift_len:]+chars[: shift_len]
08:03 then print "Actual String:",s
08:11 then print "Shifted String:", "".join(shifted_chars)
08:28 As we move the slider, we see that shifting is taking place.
08:40 Sometimes we want the user to have only a given set of options.
08:44 We use a list of items as the default argument in such situations.
08:50 So we can type @interact
08:57 then def str_shift(s="STRING",shift=(0..8), direction=["Left","Right"]):
09:10 then next line shift_len=shift modulus len(s)
09:24 then chars=list(s)
09:26 if direction=="Right" colon
09:32 then shifted_chars=chars[-shift_len colon]+chars[colon -shift_len]
10:01 else colon shifted_chars=chars[shift_len colon]+chars[colon shift_len]
10:26 then type print "Actual String:",s
10:32 then print "Shifted String:", ""
10:52 then dot join(shifted_chars)
11:01 We can see that buttons are displayed which enables us to select from a given set of options.
11:11 We see that, as we select left or right button, the shifting takes place appropriately.
11:18 Thus, we have learnt how to use the @interact feature of SAGE for better demonstration.
11:24 Now we shall look at how to use SAGE worksheets for collaborative learning.
11:30 The first feature we shall see is the publish feature.
11:34 Open a worksheet and in the top right, we can see a button called publish
11:40 Click on that and we get a confirmation page with an option for re-publishing.
11:52 For now lets forget that option and simply publish by clicking yes .
11:58 The worksheet is now published. Now lets sign out and go to the sage notebook home.
12:04 We see link to browse published worksheets.
12:08 Lets click on it and we can see the worksheet.
12:12 This does not require login and anyone can view the worksheet.
12:17 Alternatively, if one wants to edit the sheet, there is a link on top left corner that enables the user to download a copy of the sheet onto their home.
12:36 This way they can edit a copy of the worksheet.
12:41 We have learnt how to publish the worksheets to enable users to edit a copy.
12:45 Next, we shall look at how to enable users to edit the actual worksheet itself.
12:51 Let us open the worksheet and we see a link called share on the top right corner of the worksheet.
13:03 Click the link and we get a box where we can type the usernames of users whom we want to share the worksheet with.
13:10 We can even specify multiple users by separating their names using commas.
13:15 Once we have shared the worksheet, the worksheet appears on the home of shared users.
13:22 This brings us to the end of this tutorial.
13:24 In this tutorial, we have learnt to, Use interactive features of SAGE using @interact .
13:30 then publishing our work.
13:32 then edit a copy of one of the published worksheets.
13:35 then share the worksheets with fellow users.
13:39 Here are some self assessment questions for you to solve
13:44 Which default argument, when used with @interact gives a slider starting at 0 and ending in 10.
13:52 options are (0..11)
13:54 then range(0, 11), Then [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] separated by comma
14:01 then in brackets (0..10)
14:05 What is the input widget resulted by using n = [2, 4, 5, 9]\ in the default arguments along with @interact.
14:23 options are input field, set of buttons, slider, None
14:29 Now we will look at the answers,
14:31 The default argument, used with @interact which gives a slider starting at 0 and ending in 10 is (0..10).
14:42 The input widget resulted by using n = [2, 4, 5, 9] in the default arguments along with @interact will be a set of buttons that is the second one.
14:57 Hope you have enjoyed this tutorial and found it useful.
15:01 Thank you!

Contributors and Content Editors

Gaurav, Minal, PoojaMoolya, Sneha