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 "_".