#coding=utf-8
def Total_number_of_students(boys, girls):
print "There are %d boys within the environment." % boys
print "There are %d girls within the environment.\n" % girls
def Total_number_of_students(boys, girls):
print "There are %d boys within the environment." % boys
print "There are %d girls within the environment.\n" % girls
#运行方式一:数字
print "Here's the most simple way to operate this function by using numbers"
Total_number_of_students(4, 5)
print "Here's the most simple way to operate this function by using numbers"
Total_number_of_students(4, 5)
#运行方式二:变量
print "Here's another way to make the function works by working with arguments."
boys = 10
girls = 20
Total_number_of_students(boys, girls)
print "Here's another way to make the function works by working with arguments."
boys = 10
girls = 20
Total_number_of_students(boys, girls)
#运行方式三: 数学表达式
print "Here's another way to import numbers to functions"
Total_number_of_students(10 + 3, 10 + 4)
print "Here's another way to import numbers to functions"
Total_number_of_students(10 + 3, 10 + 4)
#运行方式四:数字+变量
print "Here's another way to make the function works."
Total_number_of_students(boys + 4, girls + 5)
print "Here's another way to make the function works."
Total_number_of_students(boys + 4, girls + 5)
#运行方式五:用户输入
print "Here's the fifth way to make the function meaningful by raw_input:"
boys = int(raw_input("how many boys are there within the environment?"))
girls = int(raw_input("how many girls are there within the envrionment?"))
Total_number_of_students(boys, girls)
print "Here's the fifth way to make the function meaningful by raw_input:"
boys = int(raw_input("how many boys are there within the environment?"))
girls = int(raw_input("how many girls are there within the envrionment?"))
Total_number_of_students(boys, girls)
#运行方式六:用户输入2
Note:
1)def函数名是由:字符与下划线组成的。
2)函数名后面紧跟着()
3)()里面包含着参数,多个参数用逗号隔开,切不能使用重复的参数名。
4)函数名后面的(),紧跟着:
5)4个空格缩进后,编写该函数的代码。
6)用户在终端输入时的数字也是字符串,应该使用X = int(raw_input()) 来处理