#!/usr/bin/python3 # -*- coding: utf-8 -*- # codiOpcional_03.py # Resposta a una pregunta d'un company # És quelcom que es pot fer amb Python i no en C def retorna7i2(): return 7,2 def pregunta2numeros(): a = float(input("1r número: ")) b = float(input("2n número: ")) return a,b # Les funcions en Python poden retornar més d'un valor. En C no és així. def pregunta2numerosAlhora(): a,b = input("1r i 2n número separats per un espai: ").split() return float(a),float(b) # Les funcions en Python poden retornar més d'un valor. En C no és així. x,y = retorna7i2() print("x: %d, y: %d"%(x,y)) x,y = pregunta2numeros() print("x: %d, y: %d"%(x,y)) x,y = pregunta2numerosAlhora() print("x: %d, y: %d"%(x,y))