diff options
author | Prabhu Ramachandran | 2017-02-07 23:19:47 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2017-02-07 23:19:47 +0530 |
commit | 85bdab6f2ffb381dcf654c395732ba0038816c5a (patch) | |
tree | 66e7ac3477b3ca5c8b0e7d7452f0e5d2e7d005f8 /basic_python | |
parent | 5bcd987d702e5e8653538713c0f48889853eef7a (diff) | |
download | python-workshops-85bdab6f2ffb381dcf654c395732ba0038816c5a.tar.gz python-workshops-85bdab6f2ffb381dcf654c395732ba0038816c5a.tar.bz2 python-workshops-85bdab6f2ffb381dcf654c395732ba0038816c5a.zip |
Fix some errors in the slides.
Diffstat (limited to 'basic_python')
-rw-r--r-- | basic_python/control_flow.tex | 4 | ||||
-rw-r--r-- | basic_python/core_data_structures.tex | 22 | ||||
-rw-r--r-- | basic_python/practice_basics.tex | 6 |
3 files changed, 17 insertions, 15 deletions
diff --git a/basic_python/control_flow.tex b/basic_python/control_flow.tex index 373b1a6..25d9cbc 100644 --- a/basic_python/control_flow.tex +++ b/basic_python/control_flow.tex @@ -174,7 +174,7 @@ In []: while b < 30: \begin{lstlisting} In []: a, b = 0, 1 In []: while b < 30: - ...: print(b, end='') + ...: print(b, end=' ') ...: a, b = b, a + b ...: ...: @@ -394,7 +394,7 @@ while x < 1000: \item Conditionals: \kwrd{if elif else} \item Looping: \kwrd{while} \& \kwrd{for} \item \typ{range} - \item \kwrd{break, continue, while} + \item \kwrd{break, continue, pass} \item Solving simple problems \end{itemize} \end{frame} diff --git a/basic_python/core_data_structures.tex b/basic_python/core_data_structures.tex index 25acd28..4752931 100644 --- a/basic_python/core_data_structures.tex +++ b/basic_python/core_data_structures.tex @@ -113,7 +113,7 @@ In []: num \begin{lstlisting} In []: del num[1] - In []: p.remove(6) + In []: num.remove(3) \end{lstlisting} \begin{itemize} \item \alert{When removing by value, first element is removed} @@ -128,12 +128,13 @@ In []: num In []: a \end{lstlisting} \begin{itemize} - \item \texttt{sort} method sorts the list in-place - \item Use \texttt{sorted} if you require a new list + \item \typ{sort} method sorts the list in-place + \item Use \typ{sorted} if you require a new list + \item Pass \typ{reverse=True} to reverse the ordering \end{itemize} \begin{lstlisting} In []: a = [5, 1, 6, 7, 7, 10] - In []: sorted(a) + In []: sorted(a, reverse=True) In []: a \end{lstlisting} \end{frame} @@ -263,14 +264,15 @@ In []: tuple('hello') \begin{frame}[fragile] \frametitle{Solution - Day of the Week?} + \small \begin{lstlisting} -In []: week = 'mon tue wed thu fri sat sun'.split() -In []: s = 'Sunday' -In []: s.lower()[:3] in week +week = 'mon tue wed thu fri sat sun'.split() +s = 'Sunday' +s.lower()[:3] in week \end{lstlisting} OR \begin{lstlisting} -In []: s[:3].lower() in week +s[:3].lower() in week \end{lstlisting} \end{frame} @@ -488,14 +490,14 @@ print((yyyy, mm, dd)) \end{lstlisting} \end{frame} -\begin{frame}[fragile] +\begin{frame}[fragile,plain] \frametitle{Operations on Sets} \begin{lstlisting} In []: f10 = set([1, 2, 3, 5, 8]) In []: p10 = set([2, 3, 5, 7]) \end{lstlisting} \begin{itemize} - \item Mathematical operations performed on sets, can be performed + \item Mathematical operations can be performed on sets \end{itemize} \begin{itemize} \item Union diff --git a/basic_python/practice_basics.tex b/basic_python/practice_basics.tex index 898a1ad..37e535c 100644 --- a/basic_python/practice_basics.tex +++ b/basic_python/practice_basics.tex @@ -56,7 +56,7 @@ from __future__ import print_function \frametitle{Possible solution} \begin{lstlisting} name = input() # Or raw_input() - print("Hello", name) + print("hello", name) \end{lstlisting} \end{frame} @@ -75,7 +75,7 @@ from __future__ import print_function \frametitle{Possible solution} \begin{lstlisting} name = input("Please enter your name: ") -print("Hello", name) +print("hello", name) \end{lstlisting} \end{frame} @@ -191,7 +191,7 @@ print("Hello", name) \frametitle{Possible solution} \begin{lstlisting} name = input() - print("Hello", name.upper()) + print(name.upper()) \end{lstlisting} \end{frame} |