SlideShare una empresa de Scribd logo
1 de 40
Learn Python the Hard Way
Exercises 1 – 12

http://learnpythonthehardway.org/
Exercise 1: Quotation marks
Which of these will throw an error?
a)
b)
c)
d)

print "They wouldn't do that."
print 'They wouldn't do that.'
print 'They wouldn't do that.'
print "They wouldn't do that.'
Exercise 2: Comments
Which line is commented out?
a) print "Fourscore and seven years"
b) # print "Fourscore"
c) print "Eighty years" # this is fourscore years
Which one will print blank lines?
1) print "Fourscore and seven years ago"
#
#
print "Our fathers brought forth"
2) print "Fourscore and seven years ago"
print
print
print "Our fathers brought forth"
Exercise 3: Math
Which one of these would give a different
answer than the others?
a)
b)
c)
d)
e)

4+6/3+5
4 + (6 / 3) + 5
(4 + 6) / 3 + 5
(4 + 6 / 3) + 5
4 + (6 / 3 + 5)
PEMDAS
•
•
•
•
•
•

P
E
M
D
A
S

()
exponents, e.g. 10**2
*
/
+
–
But …
PEMDAS is not the whole story

•P ()
• E exponents, e.g. 10**2
• MD * / %
• AS + –
See http://en.wikipedia.org/wiki/Order_of_operations
Exercise 4: Math
What is the answer Python will give to all of
these?
a)
b)
c)
d)

5 > 10
10 < 2
1444 < 1443
1>2
Exercise 4: Math
True or False:
<
>
<=

>=

==

!=

More about True and False to come, in Zed’s
exercise 27.
(Note: In Python, these values always start with
an uppercase letter.)
Exercise 5: Integers and floats
What is the answer Python will give to this?

1/4
Exercise 5: Integers and floats
What is the answer Python will give to this?

1 / 4.0
Learn this!

>>> 1 / 4
0
>>>

>>> 1 / 4.0
0.25
>>>

integer

float
Exercise 6: Modulus
What is the answer Python will give to all of
these?
a)
b)
c)
d)

4%2
10 % 2
144 % 12
100 % 25
Modulo
The modulus operand is commonly used to find out if a
number is odd or even.

%
Don’t get confused: In Python, the percent sign (yes,
the same character, but used differently) is also used
for format strings, as seen first in Exercise 5. (You’ll be
seeing even more of that!)
Modulo (also modulus)
What will this return?
(That is, what answer will Python give?)

115 % 11
Variables
Variables
Name

apple

Value
Variables
Variables
Variables
Name

Value
Variables
Name

Value
Variables
Name

Value

57
Variables
Name

Value
Any questions?
“Format strings”
• %s %d %r %f
• Each one is slightly different
• They are a kind of shorthand for working with
variables in Python
• NOTE! These are NOT variables!
• Zed also calls these “format characters”
• NOTE! This is NOT modulus!
%r %s %d
Not all the same.
Notice how %r in this case returns
something very different from %s
String formatting continued
•
•
•
•

%s string: use this for text
%d use this for integers (no decimal places)
%f float: shows up to 6 decimal places
%r representation: works for numbers and
strings, but (usually) adds quotation marks *

* Zed says, “The %r is best for debugging.”
(But you don’t really know what debugging is.)
The value of “play”
(an essential part of learning to code)
n newline (line break)
t tab (indent)
The backslash  is
“the escape character.”
Putting things together
a = "Mary had a little lamb."
b = "Its fleece was white as snow."
c = "And everywhere that Mary went"
d = "The lamb was sure to go."
print "nn%snt%sn%snt%snn" % (a, b, c, d)
What would happen if the order were changed to: (d, c, b, a)
Running that program …
Escapes
Zed says memorize all of these. I don’t think
that’s necessary.
But do memorize this:

The backslash  is the escape character.
Escapes!
raw_input( )
Zed’s exercises 11 and 12 introduce this.
raw_input( )
Learn Python the Hard Way
Exercises 1 – 12
(we’re just getting started)

Más contenido relacionado

Similar a Learning Python - Week 1

Similar a Learning Python - Week 1 (20)

Lập trình C
Lập trình CLập trình C
Lập trình C
 
Basics of Programming - A Review Guide
Basics of Programming - A Review GuideBasics of Programming - A Review Guide
Basics of Programming - A Review Guide
 
ForLoops.pptx
ForLoops.pptxForLoops.pptx
ForLoops.pptx
 
Lo 16
Lo 16Lo 16
Lo 16
 
ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1
 
50 must know coding interview questions
50 must know coding interview questions50 must know coding interview questions
50 must know coding interview questions
 
Ggplot2 work
Ggplot2 workGgplot2 work
Ggplot2 work
 
Learn python
Learn pythonLearn python
Learn python
 
1) sequences -_leap_frog
1) sequences -_leap_frog1) sequences -_leap_frog
1) sequences -_leap_frog
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt17
ppt17ppt17
ppt17
 
ppt30
ppt30ppt30
ppt30
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 

Más de Mindy McAdams

Multimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the ClassroomMultimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the ClassroomMindy McAdams
 
Summary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshopSummary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshopMindy McAdams
 
U.S. j-schools and digital skills
U.S. j-schools and digital skills U.S. j-schools and digital skills
U.S. j-schools and digital skills Mindy McAdams
 
New skill sets for journalism
New skill sets for journalismNew skill sets for journalism
New skill sets for journalismMindy McAdams
 
Journalism blogs: An introduction
Journalism blogs: An introduction Journalism blogs: An introduction
Journalism blogs: An introduction Mindy McAdams
 
Why Your Newsroom Should Be Using WordPress - ONA13
Why Your Newsroom Should Be Using WordPress - ONA13Why Your Newsroom Should Be Using WordPress - ONA13
Why Your Newsroom Should Be Using WordPress - ONA13Mindy McAdams
 
Journalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not NewspapersJournalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not NewspapersMindy McAdams
 
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 CanvasMindy McAdams
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOMMindy McAdams
 
HTML and Responsive Design
HTML and Responsive Design HTML and Responsive Design
HTML and Responsive Design Mindy McAdams
 
Design Concepts and Web Design
Design Concepts and Web DesignDesign Concepts and Web Design
Design Concepts and Web DesignMindy McAdams
 
Freedom of Speech - Louis Brandeis
Freedom of Speech - Louis BrandeisFreedom of Speech - Louis Brandeis
Freedom of Speech - Louis BrandeisMindy McAdams
 
Networked Information Economy / Benkler
Networked Information Economy / BenklerNetworked Information Economy / Benkler
Networked Information Economy / BenklerMindy McAdams
 
Convergence Culture / Jenkins
Convergence Culture / JenkinsConvergence Culture / Jenkins
Convergence Culture / JenkinsMindy McAdams
 
How to Share Your Digital Stories
How to Share Your Digital StoriesHow to Share Your Digital Stories
How to Share Your Digital StoriesMindy McAdams
 

Más de Mindy McAdams (20)

Just Enough Code
Just Enough CodeJust Enough Code
Just Enough Code
 
Multimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the ClassroomMultimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the Classroom
 
Summary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshopSummary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshop
 
Crowdsourcing
CrowdsourcingCrowdsourcing
Crowdsourcing
 
U.S. j-schools and digital skills
U.S. j-schools and digital skills U.S. j-schools and digital skills
U.S. j-schools and digital skills
 
New skill sets for journalism
New skill sets for journalismNew skill sets for journalism
New skill sets for journalism
 
Journalism blogs: An introduction
Journalism blogs: An introduction Journalism blogs: An introduction
Journalism blogs: An introduction
 
Why Your Newsroom Should Be Using WordPress - ONA13
Why Your Newsroom Should Be Using WordPress - ONA13Why Your Newsroom Should Be Using WordPress - ONA13
Why Your Newsroom Should Be Using WordPress - ONA13
 
Journalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not NewspapersJournalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not Newspapers
 
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
 
Beginning jQuery
Beginning jQueryBeginning jQuery
Beginning jQuery
 
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
HTML and Responsive Design
HTML and Responsive Design HTML and Responsive Design
HTML and Responsive Design
 
Design Concepts and Web Design
Design Concepts and Web DesignDesign Concepts and Web Design
Design Concepts and Web Design
 
Learning Python
Learning PythonLearning Python
Learning Python
 
Freedom of Speech - Louis Brandeis
Freedom of Speech - Louis BrandeisFreedom of Speech - Louis Brandeis
Freedom of Speech - Louis Brandeis
 
Networked Information Economy / Benkler
Networked Information Economy / BenklerNetworked Information Economy / Benkler
Networked Information Economy / Benkler
 
Convergence Culture / Jenkins
Convergence Culture / JenkinsConvergence Culture / Jenkins
Convergence Culture / Jenkins
 
How to Share Your Digital Stories
How to Share Your Digital StoriesHow to Share Your Digital Stories
How to Share Your Digital Stories
 

Último

Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 

Último (20)

Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 

Learning Python - Week 1

Notas del editor

  1. SOURCE http://learnpythonthehardway.org/book/
  2. ANSWER: b and d Quotation marks. NOTE: c is okay because it includes an escape character: \’ (It is DIFFERENT from b for that reason.)
  3. ANSWER: b C has part of the line commented out. In b, the complete line is commented out.
  4. Related to making comments. The second example will print two blank lines. The top example prints NO blank lines.
  5. ANSWER: c Because addition would not be done first, otherwise. Only in c will the addition be done first.
  6. PEMDAS is a mnemonic, but it doesn’t include modulo! (not explicitly)
  7. See table at bottom - http://en.wikipedia.org/wiki/Order_of_operationsPython is NOT the only language that follows PEMDAS.
  8. ANSWER: False (with a capital F)
  9. ANSWER: 0 (see next slide)
  10. ANSWER: 0.25 Floating point.
  11. Floats vs. integers. Floats have decimals and integers do not.
  12. CODE EXAMPLE. Floats and integers. TRY THIS YOURSELF.
  13. ANSWER: 0, because there is no remainder for any of them Modulus.
  14. “In computing, the modulo (sometimes called modulus) operation finds the remainder of division of one number by another.” http://en.wikipedia.org/wiki/Modulo_operation
  15. ANSWER: 5 (the remainder) But see - http://forums.udacity.com/questions/1001665/python-help-with-modulus Example: - 7 % 5 -&gt; 3 but 7 % 5 -&gt; 2
  16. (Exercise 4 LPTHW) Variables consist of two things, a name and a value.
  17. I think of variables as containers. They can hold all kinds of values. You can name them almost anything.
  18. The name is used in our code to represent the contents – but the contents (the value) can change.
  19. CODE EXAMPLE. Changing the value of some variables.
  20. Again: Variables consist of two things, a name and a value.
  21. Thevalue. can change, while the name stays the same.
  22. Thevalue. can change, while the name stays the same.
  23. Thevalue. can change, while the name stays the same.
  24. CODE EXAMPLE. Any questions? TRY THIS YOURSELF.
  25. Also called formatters (“short abbreviated variable names”) – Zed introduces these in exercise 5.
  26. CODE EXAMPLE. Each one has different abilities. Play with these yourself until you understand them.
  27. CODE EXAMPLE. Best example I have seen of how %r produces a different result from %s or %d or %f.
  28. http://docs.python.org/2/library/stdtypes.html#string-formattingIntegers are negative or positive numbers without decimals or fractions.
  29. Playing with code at the command line – and writing lines in your program for which you don’t know how they will come out – this is a big part of how we learn.
  30. CODE EXAMPLE. Playing with escape characters: \n and \t
  31. Same thing, just with color added. Note that each of these four variables contains a string. Therefore, the format character is %s for each one.
  32. Check out how the ”triple double-quotes” and the ”triple single-quotes” work. TRY THEM OUT.
  33. CODE EXAMPLE. Notice that the \n added an extra line for each line – the way it was typed, each line would have broken at the end anyway.
  34. LPTHW Exercise 10 – memorize\n and \\ and \’ -- it’s enough.
  35. CODE EXAMPLE. Demonstrating \n and \\ and \&quot;
  36. Zed’s exercises 11 and 12 introduce this.
  37. CODE EXAMPLE. LPTHW Exercises 11 and 12 – use of raw_input () to accept typing from the user while the program is running.
  38. Mindy McAdams - CONTACT – http://mindymcadams.com/