input_output/slides.org
author amit
Tue, 26 Oct 2010 15:44:09 +0530
changeset 349 9ced58c5c3b6
parent 276 89437325b326
permissions -rw-r--r--
Added long answer type problems in all scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
276
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
#+LaTeX_CLASS: beamer
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     2
#+LaTeX_CLASS_OPTIONS: [presentation]
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
#+BEAMER_FRAME_LEVEL: 1
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     5
#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     7
#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     8
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
#+LaTeX_CLASS: beamer
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
#+LaTeX_CLASS_OPTIONS: [presentation]
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    13
#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    14
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    15
#+LaTeX_HEADER: \usepackage{listings}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    16
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    17
#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    18
#+LaTeX_HEADER:  commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    19
#+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    20
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    21
#+TITLE:    I/O
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    22
#+AUTHOR:    FOSSEE
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    23
#+EMAIL:     
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
#+DATE:    
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
#+DESCRIPTION: 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    27
#+KEYWORDS: 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    28
#+LANGUAGE:  en
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
#+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    30
#+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    31
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
* Outline
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    33
  - Showing output to the user.
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    34
  - Taking input from the user. 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    35
* Question 1
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    36
  What happens when you do ~print "x is %d y is %f" %(x, y)~
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    37
* Solution 1
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    38
  ~int~ value of ~x~ and ~float~ value of ~y~ are printed corresponding to the
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    39
  modifiers used in the ~print~ statement
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    40
* Question 2
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    41
  Enter the number 5.6 as input and store it in a variable called
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    42
  ~c~. 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    43
* Solution 2
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
  #+begin_src python
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    45
    In []: c = raw_input() 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    46
    5.6
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    47
    In []: c
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    48
  #+end_src
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    49
* Question 3
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    50
  What happens when you do not enter anything and hit enter
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    51
* Solution 3
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    52
  #+begin_src python
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    53
    In []: c = raw_input() 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    54
    <RET>
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    55
    In []: c
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    56
  #+end_src
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    57
* Question 4
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    58
  How do you display a prompt and let the user enter input in a new line
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    59
* Solution 4
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    60
  #+begin_src python
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    61
    In []: ip = raw_input("Please enter a number in the next line\n> ")
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    62
  #+end_src
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    63
* Summary
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    64
  You should now be able to --
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    65
   + Print a value "as is" 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    66
   + Print a value using using modifiers
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    67
   + Accept input from user
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    68
   + Display a prompt before accepting input
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    69
* Thank you!
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    70
#+begin_latex
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    71
  \begin{block}{}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    72
  \begin{center}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    73
  This spoken tutorial has been produced by the
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    74
  \textcolor{blue}{FOSSEE} team, which is funded by the 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    75
  \end{center}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    76
  \begin{center}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    77
    \textcolor{blue}{National Mission on Education through \\
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    78
      Information \& Communication Technology \\ 
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    79
      MHRD, Govt. of India}.
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    80
  \end{center}  
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    81
  \end{block}
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    82
#+end_latex
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    83
89437325b326 Slides for I/O LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    84