summaryrefslogtreecommitdiff
path: root/getting_started_with_for/slides.org
diff options
context:
space:
mode:
authorJovina2011-05-25 16:29:48 +0530
committerJovina2011-05-25 16:29:48 +0530
commit58cdb783e3e48d859cbc776373da257bf7b22cbe (patch)
tree2add894bf98e308e2080221e5dec8b2bb82f16e9 /getting_started_with_for/slides.org
parent37051a2dc7b8c0cd47f2e91391612887c0f1adb9 (diff)
downloadst-scripts-58cdb783e3e48d859cbc776373da257bf7b22cbe.tar.gz
st-scripts-58cdb783e3e48d859cbc776373da257bf7b22cbe.tar.bz2
st-scripts-58cdb783e3e48d859cbc776373da257bf7b22cbe.zip
Modified the scripts and slides in module 2.
Diffstat (limited to 'getting_started_with_for/slides.org')
-rw-r--r--getting_started_with_for/slides.org29
1 files changed, 20 insertions, 9 deletions
diff --git a/getting_started_with_for/slides.org b/getting_started_with_for/slides.org
index f922baa..aafe1bb 100644
--- a/getting_started_with_for/slides.org
+++ b/getting_started_with_for/slides.org
@@ -54,6 +54,9 @@
- Use ``range()`` function.
- Write blocks in python interpreter
- Write blocks in ipython interpreter.
+* Pre-requisite
+ Spoken tutorial on-
+ - Getting started with Lists
* Whitespace in Python
- Whitespace is significant
- blocks are visually separated
@@ -64,7 +67,7 @@
: Block B
: Block A
~Block B~ is an inner block and is indented using 4 spaces
-* Question 1
+* Exercise 1
Write a ~for~ loop which iterates through a list of numbers and find
the square root of each number.
:
@@ -86,13 +89,13 @@
- Save the script as ~list_roots.py~
- Run in ~ipython~ interpreter as,
: In []: %run -i list_roots.py
-* Question 2
+* Exercise 2
Print the square root of numbers in the list.
:
Numbers are,
: 7225, 3268, 3364, 2966, 7056, 5625, 729, 5547,
: 7056, 576, 2916
-* Question 3
+* Exercise 3
Find out the cube of all the numbers from 1 to 10.
:
/do it in the python interpreter/
@@ -103,7 +106,7 @@
- /example:/
- range(1, 20) - /generates integers from 1 to 20/
- range(20) - /generates integers from 0 to 20/
-* Question 4
+* Exercise 4
Print all the odd numbers from 1 to 50.
* Summary
In this tutorial,we learnt to,
@@ -117,6 +120,7 @@
- True
- False
+
2. Write a code using ``for`` loop to print the product of all
natural numbers from 1 to 20.
@@ -124,14 +128,21 @@
3. What will be the output of-
range(1,5)
* Solutions
- 1. False
+ - False
+
- 2. y = 1
- for x in range(1,21):
- y*=x
+ - y = 1\\
+ for x in range(1,21):\\
+ y*=x\\
print y
+
+
+ -
+ #+ begin_src python
+ [1,2,3,4]
+ #+ end_src
+
- 3. [1,2,3,4]
*
#+begin_latex
\begin{block}{}