intodruccion python 2
description
Transcript of intodruccion python 2
![Page 1: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/1.jpg)
Click to edit Master subtitle styleDisplaying text
Susan Ibach | Technical EvangelistChristopher Harrison | Content Developer
![Page 2: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/2.jpg)
Have you ever used a computer to
• Read a book?
• Read a movie review?
• Read instructions on how to clean crayon off your walls?
• Learn all about the capybara?
![Page 3: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/3.jpg)
Many computer programs provide information• One of the simplest but important things you need
the ability to do in your code is display text
![Page 4: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/4.jpg)
The print statement is used to display text
print('Hickory Dickory Dock! The mouse ran up the clock')
print("Hickory Dickory Dock! The mouse ran up the clock")
You can use single quotes or double quotes
![Page 5: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/5.jpg)
DEMOPrinting text
![Page 6: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/6.jpg)
Click to edit Master subtitle style
Multiple lines
![Page 7: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/7.jpg)
print("It's a beautiful day in the neighborhood")
print('It's a beautiful day in the neighborhood')
Does it matter if you use single or double quotes?
Only if the string you are displaying contains a single or double quote.
It’s a good habit to pick one and stick with it as much as possible.
![Page 8: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/8.jpg)
What if I want my text to appear on multiple lines?
print('Hickory Dickory Dock!')print('The mouse ran up the clock')
You can use multiple print statements
![Page 9: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/9.jpg)
You can also use “\n” to force a new line
print('Hickory Dickory Dock!\nThe mouse ran up the clock')
![Page 10: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/10.jpg)
Here’s a neat Python trick: triple quotes!
print("""Hickory Dickory Dock! The mouse ran up the clock""")
When you put the string in triple quotes, it will be displayed the way you have the string in the text editor
print('''Hickory Dickory Dock!The mouse ran up the clock''')
![Page 11: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/11.jpg)
DEMOLine Management
![Page 12: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/12.jpg)
Click to edit Master subtitle style
Same problem, multiple solutions
![Page 13: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/13.jpg)
Which do you think is better?
print('Hickory Dickory Dock!')print('The mouse ran up the clock')
print('Hickory Dickory Dock!\nThe mouse ran up the clock')
print('''Hickory Dickory Dock!The mouse ran up the clock''')
![Page 14: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/14.jpg)
• There is often more than one way to solve the same problem
• Sometimes it really doesn’t matter which way you do it, as long as it works!
Geek Tips
![Page 15: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/15.jpg)
DEMOMultiple options, same output
![Page 16: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/16.jpg)
Click to edit Master subtitle style
When good code goes bad...
![Page 17: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/17.jpg)
• It’s okay to make mistakes in your code
• All programmers make typing mistakes and coding mistakes
There is another important programming concept you need to learn as well
![Page 18: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/18.jpg)
So it might be useful to practice finding our mistakes
print(Hickory Dickory Dock) print('It's a small world')print("Hi there')prnit("Hello World!")
print('Hickory Dickory Dock') print("It's a small world") print("Hi there") print("Hello World!")
![Page 19: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/19.jpg)
Your challenge should you choose to accept it• Write a program that will display the following poem
on the screen
There once was a movie star iconwho preferred to sleep with the light on.They learned how to codea device that sure glowedand lit up the night using Python!
![Page 20: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/20.jpg)
• You can now write a computer program that will share information with a user
Congratulations!
![Page 21: intodruccion python 2](https://reader035.fdocuments.us/reader035/viewer/2022062308/563dbb11550346aa9aa9fe49/html5/thumbnails/21.jpg)
©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.