Stupid way to learn python exercises 5 more variables and print

Source: Internet
Author: User

Exercise 5 mainly reviews the use of variables in the previous exercise and uses the formatting characters for the first time.

The code is as follows:

My_name = ' Zed A. Shaw '
my_age = #not a lie
my_height = #inch
my_weight = 180 #lbs
my_eyes = ' Blue '  C4/>my_teeth = ' White '
my_hair = ' Brown '

print ("Let's" talk about my%s. "%my_name)
print" He's%d inchs tall. " %my_height
print "he"%d pounds heavy. "%my_weight
print" actually that's not too heavy. "
Print "He" got%s eyes and%s hair. "% (My_eyes,my_hair)
print" his teeth are usually%s depending on the coffee. " %my_teeth

#this Line are tricky,try to get it exactly right
print ' If I add%d,%d and%d I get%d. '% (My_age, M Y_height, My_weight, My_age+my_height+my_weight)
The results of the operation are as follows:

MyStuff simengred$ python ex5.py Let's talk about my
Zed A. Shaw.
He's inchs tall.
He ' s 180 pounds heavy.
Actually that ' s not too heavy.
He ' s got Blue eyes and Brown hair.
His teeth are usually white depending on the coffee.
If I add, and 180 I get 289.

Named rules for variables:

Variable names are not limited in length, but the characters must be letters, numbers, or underscores (_), not spaces, hyphens, punctuation marks, quotes, or other characters. The first character of a variable name cannot be a number, but must be a letter or underscore. Python is case-sensitive. You cannot use the Python keyword as a variable name. There are also some special uses of variable names that start with "_".


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.