Exercise 11: Asking questions
I've had a lot of print-related exercises to get you used to writing simple things, but simple things are a little boring and now it's time to keep up. All we have to do now is read the data into your program. This may be a bit difficult for you, you may not understand, but you need to believe me, regardless of the problem. Just do a few exercises and you'll understand.
The general software does the main thing is the following:
1. Input of the recipient.
2. Change the input.
3. Print out the changed input.
So far you have only printed, but you will not accept or modify the input of the person. You may not yet know what "input" means. So gossip less, let's start doing some exercise to see if you can understand. We'll give you more explanations in the next exercise.
1 #-- Coding:utf-8- -2 Print "How is old is you ?", 3Age =raw_input ()4 Print "How tall is you ?", 5Height =raw_input ()6 Print "How much does you weigh?", 7Weight =raw_input ()8 9 Print "So, you ' re%r old,%r tall and%r heavy."% (age, height, weight)
View Code
Note
Notice that I put a comma (comma) behind each line of print, right? In this case, print will not output new line breaks and end this line to the next line.
You should see the result:
Bonus points Exercise
1. Surf the web to find out what features Python Raw_input implements.
2. Can you find any other usage of it? Test the example you searched for online.
3. Write a paragraph in a similar format and change the question to your own.
4. In relation to escape sequences, think about why the last line ' 6\ ' 2 ' has a \ ' sequence inside. Single quotes need to be escaped, preventing it from being recognized as the end of a string. Have you noticed this?
Exercise Exercises
Stupid way to learn python (11)