Python Forum
Need help with a function that calls other functions.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with a function that calls other functions.
#1
Im pretty new at programming, but atm im trying to make a function that takes two user inputs and use the input on previously made functions.
I only need help with the last part (part 4).

(BTW some of the words are in norwegian so here are some translated word to make it easier to understand if you need it): addisjon - addition, tall - number, subtraksjon - subtraction, divisjon - division, retur - return, verdi - value, tommer - inches, beregninger - calculations, Skriv inn - write.

THANK YOU IN ADVICE!
""" 1"""

def addisjon (tall1, tall2):
    return tall1 + tall2

returverdi = addisjon (5, 5)
assert addisjon (5,5)==10
assert addisjon (-10, -10)==-20
assert addisjon (-7, 10)==3
print (returverdi)

""" 2 """

def subtraksjon (tall1, tall2):
    return tall1 - tall2


returverdi = subtraksjon (15, 6)
assert subtraksjon (15,15)==-0
assert subtraksjon (-30, 20)==-50
assert subtraksjon (-20, -10)==-10
print (returverdi)

def divisjon (tall1, tall2):
    return tall1 / tall2


returverdi = divisjon (50, 5)
assert divisjon (30, 2)==15
assert divisjon (-50, 3)==-16.666666666666668
assert divisjon (-30, -6)==5
print (returverdi)

""" 3 """

def tommerTilCm (antallTommer):
    assert antallTommer > 0
    return antallTommer * (2.54)

returverdi = tommerTilCm (12)
print (returverdi), "Cm"

""" 4 """

def skrivBeregninger():
    a=input ("Skriv inn tall 1: ")
    b=input ("Skriv inn tall 2: ")
    for a and b in skrivBeregninger():
        print (addisjon)
        print (subtraksjon)
        print (divisjon)
print (skrivBeregninger())
Reply


Messages In This Thread
Need help with a function that calls other functions. - by skurrtboi - Sep-30-2019, 06:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  asyncio calls within sync function ( Websocket on_open) orion67 0 1,424 Jan-16-2022, 11:00 AM
Last Post: orion67
  Calls to Attributes of a Class SKarimi 3 3,409 Apr-22-2021, 04:18 PM
Last Post: SKarimi
  Combine Two Recursive Functions To Create One Recursive Selection Sort Function Jeremy7 12 7,401 Jan-17-2021, 03:02 AM
Last Post: Jeremy7
  list call problem in generator function using iteration and recursive calls postta 1 1,922 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  RuntimeError: Optimal parameters not found: Number of calls to function has reached m bntayfur 0 6,157 Aug-05-2020, 04:41 PM
Last Post: bntayfur
  Run a timer when a functions starts to see how long the function takes to complete Pedroski55 2 2,022 Apr-19-2020, 06:28 AM
Last Post: Pedroski55
  How to split a string containing function calls? Metalman488 4 2,902 Oct-27-2018, 06:50 PM
Last Post: Metalman488
  call a function from other functions ... evilcode1 2 2,761 Sep-05-2018, 09:07 AM
Last Post: evilcode1
  Testing function calls jenselme 1 2,693 Jul-25-2018, 10:33 AM
Last Post: Larz60+
  argument parser: to execute single function, and subsequent functions also raghu 10 5,886 Mar-12-2018, 06:57 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020