top of page

Ein Python-Beispiel:

 

Dieses Python-Beispiel realisiert einen Grad-Umrechner zwischen Grad Fahrenheit und Grad Celsius.

Hier der Quellcode:

 

c='Y'

while c=='Y':

    print("Choose type of conversion: \n\t'CF' for Celsius -> Fahrenheit \n\t'FC' for Fahrenheit -> Celsius")

    s=input()

    if s=='CF':

        print("Insert degree Celsius: ")

        i = int(input())

        o = (i*9)/5+32

        print(i,"° C are equal to ",o,"° F",sep="")

    elif s=='FC':

        print("Insert degree Fahrenheit: ")

        i = int(input())

        o = (i-32)*5/9

        print(i,"° F are equal to ",o,"° C",sep="")

    else:

        print("Wrong input.")

 

    print("Another conversion?\n\t'Y' for YES\n\t'N' for NO")

    c = input()

    if c == 'N':

        print("Exit.")

        break

 

 

Hier finden Sie einen Link zum Online-Tutor für das Python-Beispiel.

 

Außerdem wurde das Beispiel hier eingebettet:

bottom of page