# ParametersVaryingInNumber.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-28 File created. # 2022-12-27 Converted to Python 3. # With the * notation it is possible to declare a function that # accepts a varying number of parameters. I guess only the # last formal parameter of a function can be declared this way. # given_integers references a tuple in the functions below. def print_integers( *given_integers ) : print( "\n Given integers:", end="" ) for integer_in_list in given_integers : print( " %d" % integer_in_list, end="" ) def print_string_and_integers( given_string, *given_integers ) : print( "\n " + given_string + " ", end="" ) for integer_in_list in given_integers : print( " %d" % integer_in_list, end="" ) some_int_variable = 999 another_int_variable = 444 print_integers() print_integers( 1111 ) print_integers( 3, 88, 77, 2, 5 ) print_integers( some_int_variable, another_int_variable ) print_string_and_integers( "xxx" ) print_string_and_integers( "yyy", 1111 ) print_string_and_integers( "zzz", 3, 88, 77, 2, 5 ) print( "" )