際際滷

際際滷Share a Scribd company logo
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 Zeds
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
Learning Python - Week 1
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.

%
Dont 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. (Youll 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
Learning Python - Week 1
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 dont 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)
Learning Python - Week 1
Running that program
Escapes
Zed says memorize all of these. I dont think
thats necessary.
But do memorize this:

The backslash  is the escape character.
Escapes!
raw_input( )
Zeds exercises 11 and 12 introduce this.
raw_input( )
Learn Python the Hard Way
Exercises 1  12
(were just getting started)

More Related Content

Similar to Learning Python - Week 1 (20)

L畉p tr狸nh C
L畉p tr狸nh CL畉p tr狸nh C
L畉p tr狸nh C
Viet NguyenHoang
Basics of Programming - A Review Guide
Basics of Programming - A Review GuideBasics of Programming - A Review Guide
Basics of Programming - A Review Guide
Benjamin Kissinger
ForLoops.pptx
ForLoops.pptxForLoops.pptx
ForLoops.pptx
RabiyaZhexembayeva
Lo 16
Lo 16Lo 16
Lo 16
liankei
ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1
UCLA Association of Computing Machinery
50 must know coding interview questions
50 must know coding interview questions50 must know coding interview questions
50 must know coding interview questions
Ishwar Jha
Ggplot2 work
Ggplot2 workGgplot2 work
Ggplot2 work
ARUN DN
Learn python
Learn pythonLearn python
Learn python
mocninja
1) sequences -_leap_frog
1) sequences -_leap_frog1) sequences -_leap_frog
1) sequences -_leap_frog
harlie90
ppt7
ppt7ppt7
ppt7
callroom
ppt9
ppt9ppt9
ppt9
callroom
test ppt
test ppttest ppt
test ppt
callroom
ppt18
ppt18ppt18
ppt18
callroom
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
amiable_indian
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
callroom
ppt21
ppt21ppt21
ppt21
callroom
name name2 n
name name2 nname name2 n
name name2 n
callroom
ppt2
ppt2ppt2
ppt2
callroom
ppt30
ppt30ppt30
ppt30
callroom
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom
Basics of Programming - A Review Guide
Basics of Programming - A Review GuideBasics of Programming - A Review Guide
Basics of Programming - A Review Guide
Benjamin Kissinger
Lo 16
Lo 16Lo 16
Lo 16
liankei
50 must know coding interview questions
50 must know coding interview questions50 must know coding interview questions
50 must know coding interview questions
Ishwar Jha
Ggplot2 work
Ggplot2 workGgplot2 work
Ggplot2 work
ARUN DN
Learn python
Learn pythonLearn python
Learn python
mocninja
1) sequences -_leap_frog
1) sequences -_leap_frog1) sequences -_leap_frog
1) sequences -_leap_frog
harlie90
test ppt
test ppttest ppt
test ppt
callroom
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
amiable_indian
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
callroom
name name2 n
name name2 nname name2 n
name name2 n
callroom
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom

More from Mindy McAdams (20)

Just Enough Code
Just Enough CodeJust Enough Code
Just Enough Code
Mindy McAdams
Multimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the ClassroomMultimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the Classroom
Mindy McAdams
Summary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshopSummary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshop
Mindy McAdams
Crowdsourcing
CrowdsourcingCrowdsourcing
Crowdsourcing
Mindy 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 journalism
Mindy 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 - ONA13
Mindy McAdams
Journalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not NewspapersJournalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not Newspapers
Mindy McAdams
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
Mindy McAdams
Beginning jQuery
Beginning jQueryBeginning jQuery
Beginning jQuery
Mindy McAdams
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
Mindy McAdams
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
Mindy 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 Design
Mindy McAdams
Learning Python
Learning PythonLearning Python
Learning Python
Mindy McAdams
Freedom of Speech - Louis Brandeis
Freedom of Speech - Louis BrandeisFreedom of Speech - Louis Brandeis
Freedom of Speech - Louis Brandeis
Mindy McAdams
Networked Information Economy / Benkler
Networked Information Economy / BenklerNetworked Information Economy / Benkler
Networked Information Economy / Benkler
Mindy McAdams
Convergence Culture / Jenkins
Convergence Culture / JenkinsConvergence Culture / Jenkins
Convergence Culture / Jenkins
Mindy McAdams
How to Share Your Digital Stories
How to Share Your Digital StoriesHow to Share Your Digital Stories
How to Share Your Digital Stories
Mindy McAdams
Multimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the ClassroomMultimedia Journalism Innovations in the Classroom
Multimedia Journalism Innovations in the Classroom
Mindy McAdams
Summary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshopSummary of journalism faculty curriculum workshop
Summary of journalism faculty curriculum workshop
Mindy 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 journalism
Mindy 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 - ONA13
Mindy McAdams
Journalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not NewspapersJournalism's Future: Journalism, Not Newspapers
Journalism's Future: Journalism, Not Newspapers
Mindy McAdams
Introduction to HTML5 Canvas
Introduction to HTML5 CanvasIntroduction to HTML5 Canvas
Introduction to HTML5 Canvas
Mindy McAdams
An Introduction to the DOM
An Introduction to the DOMAn Introduction to the DOM
An Introduction to the DOM
Mindy 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 Design
Mindy McAdams
Freedom of Speech - Louis Brandeis
Freedom of Speech - Louis BrandeisFreedom of Speech - Louis Brandeis
Freedom of Speech - Louis Brandeis
Mindy McAdams
Networked Information Economy / Benkler
Networked Information Economy / BenklerNetworked Information Economy / Benkler
Networked Information Economy / Benkler
Mindy McAdams
Convergence Culture / Jenkins
Convergence Culture / JenkinsConvergence Culture / Jenkins
Convergence Culture / Jenkins
Mindy McAdams
How to Share Your Digital Stories
How to Share Your Digital StoriesHow to Share Your Digital Stories
How to Share Your Digital Stories
Mindy McAdams

Recently uploaded (20)

NURSING PROCESS AND ITS STEPS .pptx
NURSING PROCESS AND ITS STEPS                 .pptxNURSING PROCESS AND ITS STEPS                 .pptx
NURSING PROCESS AND ITS STEPS .pptx
PoojaSen20
Anti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VI
Anti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VIAnti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VI
Anti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VI
Samruddhi Khonde
STOMACH Gross Anatomy & Clinical Anatomy.pptx
STOMACH Gross Anatomy & Clinical Anatomy.pptxSTOMACH Gross Anatomy & Clinical Anatomy.pptx
STOMACH Gross Anatomy & Clinical Anatomy.pptx
Sid Roy
Unit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition EnginesUnit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition Engines
NileshKumbhar21
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
Amlan Sarkar
Yale VMOC Special Report - Measles Outbreak Southwest US 3-30-2025 FINAL v2...
Yale VMOC Special Report - Measles Outbreak  Southwest US 3-30-2025  FINAL v2...Yale VMOC Special Report - Measles Outbreak  Southwest US 3-30-2025  FINAL v2...
Yale VMOC Special Report - Measles Outbreak Southwest US 3-30-2025 FINAL v2...
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
MIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert KlinskiMIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert Klinski
MIPLM
How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18
Celine George
MIPLM subject matter expert Dr Alihan Kaya
MIPLM subject matter expert Dr Alihan KayaMIPLM subject matter expert Dr Alihan Kaya
MIPLM subject matter expert Dr Alihan Kaya
MIPLM
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdfWeek 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Liz Walsh-Trevino
Role of Teacher in the era of Generative AI
Role of Teacher in the era of Generative AIRole of Teacher in the era of Generative AI
Role of Teacher in the era of Generative AI
Prof. Neeta Awasthy
Gold Spot Dairy Store Jordan Minnesota 55352
Gold Spot Dairy Store Jordan Minnesota 55352Gold Spot Dairy Store Jordan Minnesota 55352
Gold Spot Dairy Store Jordan Minnesota 55352
Forklift Trucks in Minnesota
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷sHow to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
Celine George
How to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting AppHow to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting App
Celine George
CLEFT LIP AND PALATE: NURSING MANAGEMENT.pptx
CLEFT LIP AND PALATE: NURSING MANAGEMENT.pptxCLEFT LIP AND PALATE: NURSING MANAGEMENT.pptx
CLEFT LIP AND PALATE: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
Karin Clavel - Collection Wall: Inspiring connection and collaboration
Karin Clavel - Collection Wall: Inspiring connection and collaborationKarin Clavel - Collection Wall: Inspiring connection and collaboration
Karin Clavel - Collection Wall: Inspiring connection and collaboration
voginip
Key Frameworks in Systematic Reviews - Dr Reginald Quansah
Key Frameworks in Systematic Reviews - Dr Reginald QuansahKey Frameworks in Systematic Reviews - Dr Reginald Quansah
Key Frameworks in Systematic Reviews - Dr Reginald Quansah
Systematic Reviews Network (SRN)
compiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 schemecompiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 scheme
Suvarna Hiremath
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
Mukesh Kala
NURSING PROCESS AND ITS STEPS .pptx
NURSING PROCESS AND ITS STEPS                 .pptxNURSING PROCESS AND ITS STEPS                 .pptx
NURSING PROCESS AND ITS STEPS .pptx
PoojaSen20
Anti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VI
Anti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VIAnti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VI
Anti-Fungal Agents.pptx Medicinal Chemistry III B. Pharm Sem VI
Samruddhi Khonde
STOMACH Gross Anatomy & Clinical Anatomy.pptx
STOMACH Gross Anatomy & Clinical Anatomy.pptxSTOMACH Gross Anatomy & Clinical Anatomy.pptx
STOMACH Gross Anatomy & Clinical Anatomy.pptx
Sid Roy
Unit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition EnginesUnit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition Engines
NileshKumbhar21
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...
Amlan Sarkar
MIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert KlinskiMIPLM subject matter expert Dr Robert Klinski
MIPLM subject matter expert Dr Robert Klinski
MIPLM
How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18
Celine George
MIPLM subject matter expert Dr Alihan Kaya
MIPLM subject matter expert Dr Alihan KayaMIPLM subject matter expert Dr Alihan Kaya
MIPLM subject matter expert Dr Alihan Kaya
MIPLM
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdfWeek 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Liz Walsh-Trevino
Role of Teacher in the era of Generative AI
Role of Teacher in the era of Generative AIRole of Teacher in the era of Generative AI
Role of Teacher in the era of Generative AI
Prof. Neeta Awasthy
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷sHow to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
Celine George
How to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting AppHow to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting App
Celine George
CLEFT LIP AND PALATE: NURSING MANAGEMENT.pptx
CLEFT LIP AND PALATE: NURSING MANAGEMENT.pptxCLEFT LIP AND PALATE: NURSING MANAGEMENT.pptx
CLEFT LIP AND PALATE: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
Karin Clavel - Collection Wall: Inspiring connection and collaboration
Karin Clavel - Collection Wall: Inspiring connection and collaborationKarin Clavel - Collection Wall: Inspiring connection and collaboration
Karin Clavel - Collection Wall: Inspiring connection and collaboration
voginip
Key Frameworks in Systematic Reviews - Dr Reginald Quansah
Key Frameworks in Systematic Reviews - Dr Reginald QuansahKey Frameworks in Systematic Reviews - Dr Reginald Quansah
Key Frameworks in Systematic Reviews - Dr Reginald Quansah
Systematic Reviews Network (SRN)
compiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 schemecompiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 scheme
Suvarna Hiremath
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
Mukesh Kala

Learning Python - Week 1

Editor's Notes

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