12. Integer division in old programming languages

12.1. Converting degrees using C

#include <stdio.h>

    int main(void){
        float F, C;
        printf("Fahrenheit: ");
        scanf("%f", &F);
        C = 5.0 * (F - 32.0) / 9.0;
        printf("Celsius: %2.1f\n", C);
    }

12.2. Converting degrees using Python

  • Now we will convert the previous program to Python.

F = float(input("Fahrenheit: "))
C = 5.0 * (F - 32.0) / 9.0
print("Celsius: %2.1f" % C)
    On a scale from 1 (needs improvement) to 3 (excellent), how would you rate this chapter?
  • 1
  • 2
  • 3
You have attempted of activities on this page