कंप्यूटर प्रोग्रामिंग/सबरूटीन्स/पाइथन3

विकिविश्वविद्यालय से

subroutines.py[सम्पादन | स्रोत सम्पादित करें]

# This program asks the user for a Fahrenheit temperature,
# converts the given temperature to Celsius,
# and displays the results.

def get_f():
    print("Enter Fahrenheit temperature:")
    f = float(input())
    return f

def calculate_c(f):
    c = (f - 32) * 5 / 9
    return c

def display_result(f, c):
    print(str(f) + "° Fahrenheit is " + str(c) + "° Celsius")

def main():
    f = get_f()
    c = calculate_c(f)
    display_result(f, c)

main()

कोशिश करो[सम्पादन | स्रोत सम्पादित करें]

निम्न कोड मुफ्त ऑनलाइन विकास के वातावरण में से एक में ऊपर कॉपी और पेस्ट करो या अपने खुद के कम्पाइलर/इंटरप्रेटर/आईडीई का उपयोग करें।

यह भी देखें[सम्पादन | स्रोत सम्पादित करें]