Hello everyone,
I am having trouble understanding this code: Specifically, what each line does.
Here is what I think I know.
1. Defines a function maximumValue with positional parameters.
2. Assigns a variable to the value of x
3. Uses the if structure and comparison operator to create a condition, to assign higher value or number to the maximum variable.
4. Assign y(greater value) to the maximum variable.
5. Uses the if structure and comparison operator to create a condition, to assign higher value or number to the maximum variable.
6. Assign z(greater value) to the maximum variable.
7. Return the maximum value or variable to the function.
8. Get user input, convert to integer and assigned to variable a.
9. Get user input, convert to integer and assigned to variable b.
10. Get user input, convert to integer and assigned to variable c.
11. Prints a message and the maximumValue function which arguments are assigned
to the positional parameters.
I am not sure I am getting this right, I really need a better explanation as to what is happening in each line.
Practically, I understand it, theoretically, I am not sure.
def maximumValue( x, y, z ):
maximum = x
if y > maximum:
maximum = y
if z > maximum:
maximum = z
return maximum
a = int( raw_input( "Enter first integer: " ) )
b = int( raw_input( "Enter second integer: " ) )
c = int( raw_input( "Enter third integer: " ) )
print "Maximum integer is:", maximumValue( a, b, c )
Thanks everyone.
Novice