Professional Documents
Culture Documents
Lab 11
Lab 11
I.
A.
The float function returns the floating-point value equivalent to the number passed as is or in the form
of a string. Then, a for loop was used so data can be executed repeatedly.
B. The same codes were used here and in letter A of part 1 of the activity. It uses the float function and
the for loop to execute it repeatedly. The only difference is that here, kilometer or distance is the focus
and not the temperature anymore. It has also different values.
III.
OPERATORS DESCRIPTION
%10.2f FORMAT 2 DECIMAL PLACES. THE WHOLE STRING OCCUPIES 10
CHARACTERS.
%15.2f FORMAT 2 DECIMAL PLACES. THE WHOLE STRING OCCUPIES 15
CHARACTERS
C+=10 COMPOUND ASSIGNMENT OPERATOR FOR CELCIUS. ADDS RIGHT
OPERAND TO THE LEFT OPERAND AND ASSIGN THE RESULT TO THE LEFT.
Km+=10 COMPOUND ASSIGNMENT OPERATOR FOR KILOMETERS. ADDS RIGHT
OPERAND TO THE LEFT OPERAND AND ASSIGN THE RESULT TO THE LEFT.
Km<=40 COMPOUND ASSIGNMENT OPERATOR FOR KILOMETERS. CHECK IF
OPERAND ON LEFT IS SMALLER THAN OR EQUAL TO RIGHT OPERAND.
IV.
QUESTIONS:
Used for infinite loop. The condition will be always true and so what are present inside the loop
will be executed.
If (total_gallons !=0)
It allows the program to select an action based upon the user’s input.