0

I have read other posts about the topic, but none have seemed to work for me. I'm getting an error:

TypeError: calcs() missing 3 required positional arguments: 'hrs', 'mins', and 'secs'

When I try to pass these three variables into calcs():

The purpose of the code is to see at what degrees are each of the hands on the clock at (relative to 12:00:00).

 def input_io():
    input_time = input("Please enter the time following the HH:MM:SS format - be sure to include all colons and zeros needed. (e.g. 3:45:22 should be input as 03:45:22).")

    bool_okinput = False
    while bool_okinput != True:
        if ':' not in input_time:
            input_time = input("Missing Colon - Please check the format (HH:MM:SS) and re-enter the time.")
        elif len(input_time) != 8:
            input_time = input("Too Many/Too Few Characters - Please check the format (HH:MM:SS) and re-enter the time.")
        else:
            while bool_okinput != True:

                input_time = input_time.split(":")
                hrs = int(input_time[0])
                mins = int(input_time[1])
                secs = int(input_time[2])

                if hrs > 12:
                    input_time = input(
                        "Hours is greater than 12 - Please check the format (HH:MM:SS) and re-enter the time.")
                elif mins > 59:
                    input_time = input(
                        "Minutes is greater than 59 - Please check the format (HH:MM:SS) and re-enter the time.")
                elif secs > 59:
                    input_time = input(
                        "Seconds is greater than 59 - Please check the format (HH:MM:SS) and re-enter the time.")
                else:
                    bool_okinput = True
    return [hrs, mins, secs]

inputs = input_io()
hrs = inputs[0]
mins = inputs[1]
secs = inputs[2]

def calcs(hrs, mins, secs):

    degree_mult = 360/60
    hrs_degree_mult = 360/12

    if hrs == 12:
        hrs = 1

    degrees_secs = (secs * degree_mult)
    degrees_mins = (mins * degree_mult)+(degrees_secs / 60)
    degrees_hrs = (hrs * hrs_degree_mult)+(degrees_mins / 60)+(degrees_secs / (60^2))

    return [degrees_hrs, degrees_mins, degrees_secs]

degrees = calcs()
degrees_hrs = degrees[0]
degrees_mins = degrees[1]
degrees_secs = degrees[2]

print(f"When the Time is: {hrs}:{mins}:{secs}")
print(f"Hour Hand Degrees: {degrees_hrs}")
print(f"Minute Hand Degrees: {degrees_mins}")
print(f"Second Hand Degrees: {degrees_secs}")
6
  • 3
    As the error says, you said that calcs takes three parameters (def calcs(hrs, mins, secs):), but you didn't pass any (degrees = calcs()). What are you wanting the hrs, secs and mins values to be? Commented Apr 9, 2020 at 18:52
  • @Carcigenicate I would like hrs, mins, and secs to be what the user inputs. They are to be used to calculate the return [degrees_hrs, degrees_mins, degrees_secs] Commented Apr 9, 2020 at 18:55
  • 2
    Then you need to explicitly pass that information in if you're saying that it has parameters: calcs(hrs, mins, secs). Commented Apr 9, 2020 at 18:56
  • Isn't that what def calcs(hrs, mins, secs): does? Commented Apr 9, 2020 at 18:56
  • @Carcigenicate I understand now! Thank you! Commented Apr 9, 2020 at 18:57

2 Answers 2

1

The function signature

def calcs(hrs, mins, secs):

"asks" it is sent 3 arguments when it is called.
The line

degrees = calcs()

calls said function calcs but does not send it any arguments (empty parenthesis). You'd want to send the calculated variables, in the subsequent lines, to the function upon call.

Without giving it all away, here's a hint:

degrees = calcs(already_calculated_1, already_calculated_2, already_calculated_3)
Sign up to request clarification or add additional context in comments.

Comments

0

calcs defined to receive 3 params but you invoke it without any paramater here: degrees = calcs()

1 Comment

Ah, I see now. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.