Preplp
Daily Python
Day 12Python~40 min

Functions in depth

Multiple returns and conversion utilities

Track progress0/15 days
x

What you'll learn

return tupleconversion formulasmenu
  • Return multiple values from one function
  • Organize conversion logic into functions

Lesson & examples

Read the code, then the explanation — try changing values before the project.

Multiple return values
def math_ops(a, b):
    return a + b, a - b, a * b, a / b

add, sub, mul, div = math_ops(10, 5)

Today's exercise: Temperature Converter

Convert between Celsius, Fahrenheit, and Kelvin.

Steps

  1. 1

    Conversion functions

    celsius_to_fahrenheit, fahrenheit_to_celsius, etc.

  2. 2

    Menu

    Let user pick conversion direction.

Full project source — copy into a folder or use the zip above

starter.py
def celsius_to_fahrenheit(c):
    return (c * 9 / 5) + 32

def fahrenheit_to_celsius(f):
    return (f - 32) * 5 / 9

print("1. C → F  2. F → C")
choice = input("Choice: ")
if choice == "1":
    c = float(input("Celsius: "))
    print(f"{c}°C = {celsius_to_fahrenheit(c):.1f}°F")
elif choice == "2":
    f = float(input("Fahrenheit: "))
    print(f"{f}°F = {fahrenheit_to_celsius(f):.1f}°C")

One rehearsal platform

Certification mocks, daily lessons, project labs, and in-browser drills

Structured for exam day and portfolio proof — timed tests, guided builds, and quick reps on one platform.